Skip to content

Instantly share code, notes, and snippets.

@MarshalOfficial
Created August 6, 2022 17:56
Show Gist options
  • Select an option

  • Save MarshalOfficial/8f11e4e04a1e2f5e3c313d9aff8e82e5 to your computer and use it in GitHub Desktop.

Select an option

Save MarshalOfficial/8f11e4e04a1e2f5e3c313d9aff8e82e5 to your computer and use it in GitHub Desktop.
copy table data from one db to another db in postgres
1: Create a .pgpass file in the home directory of the account that pg_dump will run as.
hostname:port:database:username:password
chmod 600 ~/.pgpass
2: sudo -u postgres -i
3: pg_dump -a -t table_to_copy source_db | psql target_db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment