2012-03-23 56 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