Skip to content

Instantly share code, notes, and snippets.

@leemour
Created April 2, 2016 12:30
Show Gist options
  • Save leemour/41417bd608336735ebaa27ea67d704c7 to your computer and use it in GitHub Desktop.
Save leemour/41417bd608336735ebaa27ea67d704c7 to your computer and use it in GitHub Desktop.
Export selected records from DB to file dump - Postgres
# For a data-only export use COPY.
# You get a file with one table row per line as plain text (not INSERT commands), it's smaller and faster:
COPY (SELECT * FROM nyummy.cimory WHERE city = 'tokio') TO '/path/to/file.csv';
# Import the same to another table of the same structure anywhere with:
COPY other_tbl FROM '/path/to/file.csv';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment