PG添加单个数据库专用账户

CREATE ROLE xxx NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN NOREPLICATION NOBYPASSRLS PASSWORD ‘xxxxxpwd’;

ALTER DATABASE “xx” OWNER TO xxx;

GRANT ALL ON SCHEMA public TO xxx;

Grant all on all tables in schema public to xxx;

select ‘ALTER TABLE ‘ || table_name || ‘ OWNER TO wf;’ from information_schema.tables where table_schema=‘public’;

或者

select case WHEN relkind= ‘r’ then

‘ALTER TABLE ‘||relname||‘ owner to oa;’

else

‘ALTER SEQUENCE ‘||relname||‘ owner to oa;’

end from pg_class where relkind in (‘r’,‘S’);

发表评论

您的邮箱地址不会被公开。 必填项已用 * 标注

滚动至顶部