pg_dump 自定义数据类型
pg_dump a custom data type
我正在将 select tables 从我的服务器传输到我的笔记本电脑以在本地工作。由于 space 我笔记本电脑的限制,转储整个数据库是不可行的。其中一列 table 是自定义数据类型,恢复时出现以下错误:
pg_restore: [archiver (db)] could not execute query: ERROR: type "custom_data_type" does not exist
有两种方法可以解决这个问题,但我无法在线找到说明:
- 确保table所依赖的数据类型包含在`pg_dump
中
- 找到自定义数据类型的创建脚本
pg_dump
有选项:
-s
--schema-only
Dump only the object definitions (schema), not data.
This option is the inverse of --data-only. It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data.
(Do not confuse this with the --schema option, which uses the word "schema" in a different meaning.)
除非您的源数据库有大量 DDL,否则应该没问题。如果您的源确实有大量 DDL,您可以使用您选择的文本编辑器从 pg_dump
输出中手动提取类型创建脚本。
我正在将 select tables 从我的服务器传输到我的笔记本电脑以在本地工作。由于 space 我笔记本电脑的限制,转储整个数据库是不可行的。其中一列 table 是自定义数据类型,恢复时出现以下错误:
pg_restore: [archiver (db)] could not execute query: ERROR: type "custom_data_type" does not exist
有两种方法可以解决这个问题,但我无法在线找到说明:
- 确保table所依赖的数据类型包含在`pg_dump 中
- 找到自定义数据类型的创建脚本
pg_dump
有选项:
-s --schema-only
Dump only the object definitions (schema), not data.
This option is the inverse of --data-only. It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data.
(Do not confuse this with the --schema option, which uses the word "schema" in a different meaning.)
除非您的源数据库有大量 DDL,否则应该没问题。如果您的源确实有大量 DDL,您可以使用您选择的文本编辑器从 pg_dump
输出中手动提取类型创建脚本。