2012-03-23 74 views
12

我正在尝试删除以前是具有相同名称'xyz'的架构所有者的角色'xyz'。我按照如下所示更改了模式所有权,并运行重新分配的所有权以防万一(尽管所有表由不同用户以超级用户权限创建)。所以,我跑所有这些:PostgreSQL拖放角色由于默认权限而失败

alter schema xyz owner to postgres; 
reassign owned by xyz to postgres; 
alter default privileges in schema seeds revoke all on tables from xyz cascade; 
alter default privileges in schema seeds revoke all on sequences from xyz cascade; 
alter default privileges in schema seeds revoke all on functions from xyz cascade; 

而仍然得到错误:

drop role xyz; 
ERROR: role "xyz" cannot be dropped because some objects depend on it 
DETAIL: owner of default privileges on new relations belonging to role xyz in schema xyz 

而且FYI:

postgres=# \du rsi 
List of roles 
Role name | Attributes | Member of 
-----------+----------------+----------- 
rsi  | No inheritance | {} 

我缺少什么?任何帮助,将不胜感激!谢谢!!

+0

将此移至dba.stackexchange.com? – 2014-04-15 13:14:17

回答

13

PostgreSQL documentation摄于ALTER DEFAULT PRIVILEGES,说明部分:

If you wish to drop a role for which the default privileges have been altered, it is necessary to reverse the changes in its default privileges or use DROP OWNED BY to get rid of the default privileges entry for the role.

另一个worthy mention在这种情况下,关于DROP OWNED BY文档也是

Because DROP OWNED only affects the objects in the current database, it is usually necessary to execute this command in each database that contains objects owned by a role that is to be removed.

因此,您的里程可能会有所不同,这意味着您可能必须在更多的数据库中发布该声明。

收到与问题中提到的相同的消息后,我试用了DROP OWNED BY声明,它工作正常。希望这可以帮助!

+5

'DROP OWNED BY USR;'后面是'DROP USER usr'''为我工作,谢谢! – cvsguimaraes 2016-01-30 00:20:57