gpt4 book ai didi

postgresql - pg_dump 自定义数据类型

转载 作者:行者123 更新时间:2023-11-29 11:33:31 25 4
gpt4 key购买 nike

我正在将选定的表格从我的服务器传输到我的笔记本电脑以在本地处理。由于笔记本电脑的空间限制,转储整个数据库是不可行的。一个表的列之一是自定义数据类型,恢复时出现以下错误:

pg_restore:[archiver (db)] 无法执行查询:错误:类型“custom_data_type”不存在

有两种方法可以解决这个问题,但我无法在线找到说明以:

  1. 确保表所依赖的数据类型包含在`pg_dump 中
  2. 找到自定义数据类型的创建脚本

最佳答案

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 输出中手动提取类型创建脚本。

关于postgresql - pg_dump 自定义数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29708226/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com