各位前輩好,我目前在嘗試開一個只讀的role,在CREATE role後,完成GRANT select權限,然後測試將role刪掉時出現以下錯誤
testDB=> drop role role01;
ERROR: role "role01" cannot be dropped because some objects depend on it
DETAIL: 4 objects in database TimestreamDB
(補充:我是使用admin role執行以上操作)
想請問以下問題:
以上若有不清楚的部分,請提出,我再補充,感謝~
select pgn.nspname as schema_name,
pgc.relname as object_name,
pgr.rolname as owner,
case pgc.relkind
when 'r' then 'TABLE'
when 'm' then 'MATERIALIZED_VIEW'
when 'i' then 'INDEX'
when 'S' then 'SEQUENCE'
when 'v' then 'VIEW'
when 'c' then 'TYPE'
else pgc.relkind::text
end as object_type
from pg_class pgc
join pg_roles pgr on pgr.oid = pgc.relowner
join pg_namespace pgn on pgn.oid = pgc.relnamespace
where pgn.nspname not in ('information_schema', 'pg_catalog')
and pgn.nspname not like 'pg_toast%'
and pgr.rolname = 'yourusername'
order by pgn.nspname, pgc.relname;
REASSIGN OWNED BY yourusername TO postgres;
先REVOKE ALL ON SCHEMA schema01 FROM role01;
然後參考這篇
看看合不合用