Created
February 15, 2023 01:31
-
-
Save fatadz/28d5c6b2787ea017ed6c900d63b384cc to your computer and use it in GitHub Desktop.
Export or dump PostgreSQL table structure and data, then import it
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
#dump 1 table | |
pg_dump -v --table=table_name --data-only --column-inserts -h 127.0.0.1 -U postgres_user postgres_db > ~/dump.sql | |
#structure and dump all tables | |
pg_dump -v -h 127.0.0.1 -U postgres_user postgres_db > ~/postgres-db.sql | |
#import | |
psql -h 127.0.0.1 -U postgres_user postgres_db < ~/postgres-db.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment