Usefull PostgreSql commands

 To show list of databases
mysql: SHOW DATABASES
postgresql: \l
postgresql: SELECT datname FROM pg_database;

To connect/use a particular database

mysql: use database_name;

Postgresql: \c database_name

 

To show list of tables in your database
mysql: SHOW TABLES
postgresql: \d
postgresql: SELECT table_name FROM information_schema.tables WHERE table_schema = ‘public’;

 

To show list of columns in a particular table / schema use :
mysql: SHOW COLUMNS
postgresql: \d table_name
postgresql: SELECT column_name FROM information_schema.columns WHERE table_name =’table‘;

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s