pg_dump如何(不)在DDL中包括每个对象的方案名称

问题描述 投票:0回答:1

我需要比较2个DB方案(DDL)-Postgress 9.5

我在两个服务器上都执行以下命令:

pg_dump -U postgres --dbname=db--schema-only -f schema.sql

但是我注意到输出的前缀之一是每个对象的方案名称,例如

CREATE FUNCTION schemeName.function_name

而另一个则不,例如:

CREATE FUNCTION function_name

pg_dump中是否有任何选项可以决定是否在输出DDL中插入方案名称?(首选项至少要删除那些模式前缀...)

postgresql ddl pg-dump db-schema
1个回答
0
投票

简而言之:你不能。但是,您可以使用sed自动完成编辑的[[most。


#!/bin/sh # dump only schema "tmp" # force quoted identifiers # use sed to strip them # [youstillneedtoremove the "CReate SCHEMA $SCH_NAME-stuff DB_NAME="postgres" pg_dump -Upostgres -n tmp --schema-only --quote-all-identifiers $DB_NAME \ | sed 's/"tmp"\.//g' > tmp_schema_stripped.sql #EOF
© www.soinside.com 2019 - 2024. All rights reserved.