省略从 pg_dumpall 创建角色

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

如何在 pg_dumpall 的输出中省略此角色创建部分:


--
-- Roles
--

CREATE ROLE admin;
ALTER ROLE admin WITH NOSUPERUSER INHERIT NOCREATEROLE CREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD 'SCRAM-SHA-';
CREATE ROLE user;
ALTER ROLE user WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD 'SCRAM-SHA-';
CREATE ROLE postgres;
ALTER ROLE postgres WITH SUPERUSER INHERIT CREATEROLE CREATEDB LOGIN REPLICATION BYPASSRLS PASSWORD 'SCRAM-SHA-';
CREATE ROLE zabbix;
ALTER ROLE zabbix WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD 'SCRAM-SHA-';

感谢您的任何提示。

postgresql pg-dumpall
1个回答
0
投票

如果使用带有 -v 选项的 grep 命令,则可以省略输出文件中不需要的行。例如,以下命令将从输出中排除 CREATE ROLE 行。

pg_dumpall -h (host) -U (username) | grep -v "CREATE ROLE" > roles_filtered.sql
© www.soinside.com 2019 - 2024. All rights reserved.