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’);