Skip to content

Instantly share code, notes, and snippets.

@luxxi
Last active August 28, 2015 23:29
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 luxxi/adfb4fc5ee4fde52d292 to your computer and use it in GitHub Desktop.
Save luxxi/adfb4fc5ee4fde52d292 to your computer and use it in GitHub Desktop.
Export data from postgresql

Use COPY TO for dump the table data in csv format.

COPY table TO '/tmp/table.csv' DELIMITER ',';

Use the COPY FROM to "paste" it in another table.

COPY another_table FROM '/tmp/table.csv' DELIMITER ',';


table and another_table must have the same structure.

Don't forget run psql and be in the right database \c database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment