postgresql - 从 pg_dump 中排除序列
问题描述
我正在创建一个 postgres 数据库(10.1)的导出,其中一些表被排除在外。我按照Is there a way to get pg_dump to exclude a specific sequence?. 但是,仍包括排除表的序列。有没有办法确保他们被拒之门外?
为了隔离问题,我创建了一个小型示例数据库,其中包含一个名为include
and的exclude
表,为每个表添加了一行,并使用此命令导出数据库:
pg_dump --host=localhost --no-owner --no-acl --verbose --schema=public --dbname=export_test --exclude-table=exclude --file=exclude_table_only.dump
转储不包括exclude
表,但确实包括序列:
...
--
-- TOC entry 198 (class 1259 OID 3818320)
-- Name: exclude_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE exclude_id_seq
...
解决方案
您应该能够使用另一个 --exclude-table 显式排除序列:
--exclude-table=exclude_id_seq
最终应该是这样的:
$ pg_dump --host=localhost --no-owner --no-acl --verbose --schema=public --dbname=export_test --exclude-table=exclude --exclude-table=exclude_id_seq --file=exclude_table_only.dump
推荐阅读
- c# - 如何在 C# 中将 EXIF 数据写入图像?
- python - 如何将多行 Python 代码转换为单行?
- python - 如何遍历模板中的多维列表/字典
- django - 带有 whitenoise.django 的 ImportError
- c++ - 如何在 g++ 中“使用 unicode 字符集”?
- python - 有没有办法在熊猫数据帧上并行化这个循环?
- reactjs - Algolia SearchBox - 我希望它仅在用户选择 SearchBox 时显示 Hits
- typescript - 使用 keyof 的参数泛型推理
- python-3.x - 将带有 texttract 模块的 Python 应用程序部署到 Google Cloud Platform
- firebase - 用于在另一个集合中的文档中查找数据的 Firestore 匹配规则