PostgreSQL: show tables, show databases, show columns, describe table

PostgreSQL is one of the best databases, which you can choose from when working on your project. If you are switching from MySQL, you will realise immediatelly that you are missing basic commands that you were used to in MySQL. Lets have a look at few basic commands.

MySQL: SHOW TABLES

PostgreSQL: \d

PostgreSQL: SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';


MySQL: SHOW DATABASES

PostgreSQL: \l

PostgreSQL: SELECT datname FROM pg_database;


MySQL: SHOW COLUMNS

PostgreSQL: \d table

PostgreSQL: SELECT column_name FROM information_schema.columns WHERE table_name ='table';


MySQL: DESCRIBE TABLE

PostgreSQL: \d+ table

PostgreSQL: SELECT column_name FROM information_schema.columns WHERE table_name ='table';