Stream exported data to a server-side program.
Section: COPY Import and Export
COPY query to program
sql
sql
COPY (SELECT * FROM public.users) TO PROGRAM 'gzip > /tmp/users.csv.gz' CSV HEADER;Explanation
See summary for usage details.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing COPY Import and Export
Client-side \copy export
Export via the client machine rather than the database server.
COPY FREEZE into fresh table
Load immutable initial data into a newly created or truncated table.