Skip to content

Instantly share code, notes, and snippets.

@joaquinmoreira
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joaquinmoreira/9392903 to your computer and use it in GitHub Desktop.
Save joaquinmoreira/9392903 to your computer and use it in GitHub Desktop.
Export rows from a select and import back in postgresql
COPY (SELECT * FROM sample_table) TO '/path/to/file';
COPY sample_table FROM '/path/to/file';
SELECT setval('sample_table_id_seq', max(id)) FROM sample_table; -- Update primary key sequence
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment