Table of Contents

PostgreSQL



SQL

Check version # select version();
Help # \?
# \h

Database

Login Database $ psql -U <USER_NAME> <DB_NAME>
Logout Database # \q
List Database # \l
Changee Database # \c <DB_NAME>
# \connect <DB_NAME>
Delete Dabase # drop database <DATABASE_NAME>;

Table

List Table # \d
# \dt
View table schema details. # \d <TABLE_NAME>
Table access rights display. # \z <TABLE_NAME>

User

Schema

Creata Database

create database <DATABASE>

\l  #List Database
drop <DATABASE>

Creata Table

create table test1 (id char(4) not null, name text not null, food text not null, PRIMARY KEY(id));

\d  #List Table with view table
\dt #List Table without view table