dijous, 14 de juny del 2012

Quick steps with postgres for MySQL admins

Connect (really we are login with postgres user):
su - postgres

show databases:
psql -l
or after connect without a database selected
\l

Connect to database:
psql [database] [username]

Show tables:
\d

Describe table:
\d+ table

Show rows per table:
SELECT schemaname,relname,n_live_tup
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC;


Quit:
\q