Search code examples
postgresqlpg-dumppg-restore

Partition table data are not restored using pg_restore in PostgreSQL


Need Help !!

While i'm going to restore a partition table using :

pg_restore -U (username) -d (Database) -p (port_number) -t (partition_table) -f (filename)

the result is success but the data in that partition table is not restored, can anyone help me ?


Solution

  • When -t is specified, pg_restore makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-partitioned table dump can be successfully restored

    However you can take dump using

    pg_dump --host=hostname --username=user -t "child_table_*" --data-only --file=dump_out.sql dbname

    and then restore it, This is probably a consequence of the design decision to have partitions visible as individual tables on the SQL level.

    please refer: https://www.postgresql.org/docs/13/app-pgrestore.html https://www.postgresql.org/docs/11/app-pgdump.html