PostgreSQL 18 · Backup and restore

Export a table to CSV

Write a table to a CSV file on your machine, from inside psql.

\copy users TO 'users.csv' WITH (FORMAT csv, HEADER)

Official PostgreSQL 18 documentation

More backup and restore commands

All backup and restore commands · PostgreSQL 18 cheatsheet

Was this page helpful?