Postgres Cheat Sheet PDF
Postgres Cheat Sheet PDF
Postgres Cheat Sheet PDF
Queries psql
SELECT name, price FROM Parts psql -h hostname -U username db-name
WHERE id=123 OR quantity>0
ORDER BY name DESC; \d -- list tables, views, seqs
\c other-db -- connect to another db
-- Average price for each vendor:
SELECT vendor_id, avg(price) from Parts -- Send query results to a file:
GROUP BY vendor_id; \copy (SELECT 2+2) TO '/tmp/outfile'