I have a production Postgresql database which consist of 70 tables. Some of them are very big and some are small. And I have my local Postgresql database on my local machine. I want to make some of my local database tables's content be the same as production ones. If I just backup some tables with pgAdmin on production database and then try to restore on my local machine I got constrain errors. Because for example table A has foreign key to table B and so on.
How could I copy some tables from production database and restore normally on my local machine which has already scheme and tables and without constrain errors?
P.s. I couldn't just dump all production database because some of tables are VERY BIG.
Dump complete production database, but without data in case of large tables:
$ pg_dump -t <VERY_BIG_TABLE_NAME> -s
If you want data also, avoid the -s
option. Since you will have to repeat this 70 times, quicker solution is dividing tables into schemas:
$ pg_dump -n <SCHEMA_NAME_WITH_VERY_BIG_TABLES> -s
$ pg_dump -n <SCHEMA_NAME_WITH_SMALL_TABLES>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With