Skip to content

Instantly share code, notes, and snippets.

@jimlambie
Created November 3, 2013 23:07
Show Gist options
  • Save jimlambie/7295892 to your computer and use it in GitHub Desktop.
Save jimlambie/7295892 to your computer and use it in GitHub Desktop.
Postgres Import/Export
# export to CSV file
psql -d <database> -c "COPY (SELECT * FROM <table_name>) TO '/full/path/to.csv' WITH CSV"
# import from CSV
psql -d <database> -c "COPY <table_name> FROM '/full/path/to.csv' DELIMITER ',' CSV"
# import SQL file
psql -d <database> -f <filename>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment