Tuesday, November 10, 2015

PostgreSQL Cheat Sheet

Open command line

sudo -u postgres psql

Quit command line


Get the current user


List databases


Connect to a database

\c dbname

List tables in a database


List columns of a table

\d tablename

Export the sql result to a CSV

Copy (Select * From tablename) To '/tmp/result.csv' With CSV;

Limit the sql result

select * from tablename limit 10;

Work with JSONB type

No comments:

Post a Comment