Created
February 1, 2016 18:05
-
-
Save ismyrnow/8eee64a86b3cf3f73988 to your computer and use it in GitHub Desktop.
Selective data migration between databases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Open a database connection | |
psql -h myserver -U myuser mydatabase | |
# Use `\copy` to copy data to a local file, not one on the server. | |
\copy (select * from mytable where ...) to 'C:\output.copy` | |
# Copy the data into the new database | |
\copy mytable from 'C:\output.copy' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doing an csv export/import with pgadmin didn't work with certain datatypes, like binary geometries and dates, and also didn't account for different ordering of columns between source and destination. This process worked around those limitations.