PostgreSQL

Updated: 05 November 2025

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