PostgreSQL is one of the best database engines for an average web project and many who moves to psql from MySQL (for example) often ask the following questions:
- What is the analog of “show tables” in Postgres?
- How can I get the list of databases in Postgres like “show databases” in MySQL?
In this quick tutorial, we’ll answer these questions, along with some other common commands which are useful.
PostgreSQL doesn’t work with original MySQL commands, but it gives similar functionality with its own commands:
SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';
SELECT datname FROM pg_database;
postgresql: SELECT column_name FROM information_schema.columns WHERE table_name =’table’;
SELECT column_name FROM information_schema.columns WHERE table_name ='
If there are any other equivalent commands you’d like to learn for Postgres which we’ve missed above, feel free to let us know in the comments section and we’ll get them added.