Monday, March 10, 2008

Get list of databases and tables in a database..Postgresql

To get list of databases in MySQL you can simply run :
SHOW DATABASES
SO what is the equivalent sql statement in Postgresql:
select datname from pg_database;

To get list of tables in a postgres database:

SELECT * FROM pg_tables;

Offcourse you can get list of tables using \dt from the command
prompt for postgres.I am just telling about doing it using sql
query which you can also use outside of command prompt for
postgres.

very simple indeed.. Isn't it;P

2 comments:

Aman said...

Thanks babu, it is quite handy.

Rakibul Hasan said...

Really great. definitely useful. I am eager to know how I can get the list of all the procedures in a particular database?