usunyu   Stay hungry. Stay foolish.

Postgres Command Tips

Create databases:

$ CREATE DATABASE name
    [ [ WITH ] [ OWNER [=] user_name ]
           [ TEMPLATE [=] template ]
           [ ENCODING [=] encoding ]
           [ LC_COLLATE [=] lc_collate ]
           [ LC_CTYPE [=] lc_ctype ]
           [ TABLESPACE [=] tablespace ]
           [ CONNECTION LIMIT [=] connlimit ] ]

Drop databases:

$ DROP DATABASE [ IF EXISTS ] name

List all databases:

$ \list
$ \l

List all tables in the current database:

$ \dt

Switch databases:

$ \connect database_name

Describe Table:

$ \d+ tablename

Resource: