Skip to content

Instantly share code, notes, and snippets.

@gbuesing
Created June 8, 2017 14:16
Show Gist options
  • Save gbuesing/5da671211a1e2ffefbf33c10e82bff08 to your computer and use it in GitHub Desktop.
Save gbuesing/5da671211a1e2ffefbf33c10e82bff08 to your computer and use it in GitHub Desktop.
Copy single row from one Postgres DB into another via psql
# database 1
# output single row in format compatible with INSERT VALUES
\copy (SELECT * FROM users WHERE email = '[email protected]') To stdout With CSV force quote * null 'NULL' quote ''''
# database 2
# insert values outputted from above command into another database
INSERT INTO users VALUES (...);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment