POSTGRESQL database useful commands
PostgreSQL Main

POSTGRESQL database useful commands – PostgreSQL open source and most advanced relational database. It is powerful with long active and good reputation for reliability, feature robustness and performance. If you are interested there is lots of information available to download and found on its official website and documentation.

If you are first time using POSTGRESQL then you need to have some POSTGRESQL database useful commands handy to operate this key-value database. When I first started using POSTGRESQL I could not find any good site which will give me beginner commands which was needed to operate database. So I have created this tutorial to give you those command which you will always needed. I will keep adding more and more tutorial on how to use PostgreSQL in future for now I am keeping this tutorial short to just have important commands and below is details:

POSTGRESQL database useful commandss

  • To see all table in sample book database: below is two command go to book db and see all tables:
POSTGRESQL database useful commands
  • POSTGRESQL database useful commands – To see list of schema on PostgreSQL database
POSTGRESQL database useful commands
  • Below will show list of command in PostgreSQL database
POSTGRESQL database useful commands
  • Help for finding all commands which you can view and use
POSTGRESQL database useful commands
  • Create table sample script (Here we are creating sample table conntries)
POSTGRESQL database useful commands
  • Now view newly created table test
POSTGRESQL database useful commands
  • Drop table test
POSTGRESQL database useful commands
  • To see all table in book database
POSTGRESQL database useful commands
  • Insert into table
POSTGRESQL database useful commands
  • Select from table
POSTGRESQL database useful commands
  • If you want to delete anything specific from countries table. Here we are deleting based on country_code
POSTGRESQL database useful commands
  • Try to insert with same primary key you will get exception
POSTGRESQL database useful commands
  • Update table and change values
POSTGRESQL database useful commands

Trigger, procedure and functions:

  • View all trigger

select * from pg_trigger;

POSTGRESQL database useful commands
  • View all trigger with source code:

\df+ in psql gives you the sourcecode.

POSTGRESQL database useful commands
  • View all store procedure

select proname,prosrc from pg_proc;

  • View procedure by name and below will show you procedure with source code:
POSTGRESQL database useful commands

For more information on Postgresql please visit : https://www.postgresql.org/

Leave a Reply

Your email address will not be published. Required fields are marked *