Skip to content

Instantly share code, notes, and snippets.

@ghl3
Last active December 21, 2015 21:39
Show Gist options
  • Select an option

  • Save ghl3/6369556 to your computer and use it in GitHub Desktop.

Select an option

Save ghl3/6369556 to your computer and use it in GitHub Desktop.
PSQL to CSV
/* Copy to a file as a csv */
Copy (SELECT * FROM foo) To '/tmp/test.csv' With CSV;
/* Copy to std::out as tab separated values */
COPY (SELECT * FROM foo) TO STDOUT WITH DELIMITER E'\t' CSV HEADER;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment