Wednesday, December 5, 2012

postgresql psql show database, table, column

SHOW TABLE:
postgresql: \d
postgresql: SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';

SHOW DATABASES
postgresql: \l
postgresql: SELECT datname FROM pg_database;

SHOW COLUMNS
postgresql: \d table
postgresql: SELECT column_name FROM information_schema.columns WHERE table_name ='table';

DESCRIBE TABLE
postgresql: \d+ table
postgresql: SELECT column_name FROM information_schema.columns WHERE table_name ='table';

RENAME DATABASE
postgresql: alter database old_name rename to new_name;

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.