Updated: 12 January 2026
Remove a PostgreSQL database called app as user app
dropdb -U app app
Dump a table to csv format file
COPY book TO '/tmp/book_entries.csv' WITH (FORMAT CSV, HEADER);
Create a temporary table from a select statement
CREATE TEMP TABLE narrow_table AS SELECT foo, bar from broad_table;
Drop a table, but only if it already exists
DROP TABLE IF EXISTS trades_snapshot