我试图删除一个角色'xyz',该角色以前是具有相同名称'xyz'的架构的所有者.我更改了架构所有权,如下所示,并运行重新分配的所有权以防万一(尽管所有表都是由具有超级用户权限的其他用户创建的).所以我运行所有这些:
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;
Run Code Online (Sandbox Code Playgroud)
仍然得到错误:
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 …Run Code Online (Sandbox Code Playgroud) 我想使用各种比较器功能在字典中订购项目.请参阅下面的示例代码.这是使用cmpRatio函数和sorted()的最后一部分,它不起作用.我不确定我做错了什么.提前感谢任何想法!
mydict = { 'a1': (1,6),
'a2': (10,2),
'a3': (5,3),
'a4': (1,2),
'a5': (3,9),
'a6': (9,7) }
# sort by first element of the value tuple: WORKS
print sorted(mydict.iteritems(), key=lambda (k,v): v[0])
# sort by second element of the value tuple: WORKS
print sorted(mydict.iteritems(), key=lambda (k,v): v[1])
# THIS is what I can't get working:
def cmpRatio(x,y):
sx = float(x[0])/x[1]
sy = float(y[0])/y[1]
return sx < sy
# sort by sum of the elements in the value tuple: DOES NOT …Run Code Online (Sandbox Code Playgroud)