首页 > 解决方案 > 在 PostgreSQL 中不使用 pg_restore 恢复分区表数据

问题描述

需要帮忙 !!

虽然我要使用以下方法恢复分区表:

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

结果是成功,但该分区表中的数据没有恢复,有人可以帮我吗?

标签: postgresqlpg-dumppg-restore

解决方案


当指定 -t 时,pg_restore 不会尝试转储所选表可能依赖的任何其他数据库对象。因此,不能保证特定分区表转储的结果可以成功恢复

但是,您可以使用转储

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

然后恢复它,这可能是设计决定的结果,即在 SQL 级别上将分区作为单个表可见。

请参考: https ://www.postgresql.org/docs/13/app-pgrestore.html https://www.postgresql.org/docs/11/app-pgdump.html


推荐阅读