-
Notifications
You must be signed in to change notification settings - Fork 1
psql Cheatsheet
Jason Lewis edited this page Aug 26, 2024
·
5 revisions
psql --help
help
General Help
\h
SQL Command Help
\?
psql Command Help
\x
\df
psql -h <localhost or IP> -p <port> -U <username> -d <database name>
NOTE: Most parameters are optional
NOTE: Case is important!
\l
\c <database name>
\d
\dt
\d <table name>
\dT
\d <type>
\copy (<query>) TO '<path to file>' DELIMITER ',' CSV HEADER;
e.g. \copy (SELECT * FROM person) TO '/home/jasonl/Desktop/sql/results.csv' DELIMITER ',' CSV HEADER;