Monday, 4 February 2013

Postgresql equivalent to show tables, show databases, describ etable

Copied from Postgresql: show tables, show databases, show columns, describe table.

-- mysql: SHOW TABLES
\d 
SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';

-- mysql: SHOW DATABASES
\l
SELECT datname FROM pg_database;

-- mysql: SHOW COLUMNS
\d <table>
SELECT column_name FROM information_schema.columns WHERE table_name ='table';

-- mysql: DESCRIBE TABLE
\d+ <table>
SELECT column_name FROM information_schema.columns WHERE table_name ='table';

Also to see the available roles:


SELECT rolname FROM pg_roles;

No comments:

Post a Comment