Tech notes

Daily notes about my IT activities.

2018-05-12

psql: cheat sheet

by hackprime

Prepaired some commands for PostgreSQL database schema investigating from command line

List databases

\list
# or
\l

Select database

\connect db_name
# or
\c db_name

List tables of database

\dt
# or
SELECT * FROM pg_catalog.pg_tables;

List columns of database table

\d+ table_name
# or
SELECT *
FROM information_schema.columns
WHERE table_schema = 'your_schema'
  AND table_name = 'your_table'