Skip to content

Catatan Ringkas

Login to PSQL CMD

psql -u 'your user name'
# after this you have to type your password

Display Databases

Untuk menampilkan data base gunakan perintah \dt

\dt
postgres=# \dt
        List of relations
 Schema | Name | Type  |  Owner
--------+------+-------+----------
 public | mx   | table | postgres

Choosing database

Untuk memilih database gunakan perintah \c [database name]

postgres=# \c DBCM-BBA
You are now connected to database "DBCM-BBA" as user "postgres".

Display informatio about table

Untuk menampilkan informasi mengenai sebuah table seperti tipe data, nama kolom, primary key serta index dan constraint gunakan \d [table name]

DBCM-BBA=# \d mx
                            Table "public.mx"
 Column |  Type   | Collation | Nullable |            Default
--------+---------+-----------+----------+--------------------------------
 id     | integer |           | not null | nextval('mx_id_seq'::regclass)
 jsonmx | json    |           | not null |
Indexes:
    "mx_pkey" PRIMARY KEY, btree (id)

More information about table definition you can visit here