【发布时间】:2021-01-16 00:33:19
【问题描述】:
我在 postgres 中有一个表 myschema 具有不同所有者的架构 - 所有者 'foo' 和所有者 'bar'
将数据库上的所有权限授予所有者“bar”,然后以用户“bar”重新登录后,我尝试使用以下命令将所有 bar 拥有的表的所有权更改为“foo”:
SELECT format(
'ALTER TABLE %I.%I.%I OWNER TO %I;',
table_catalog,
table_schema,
table_name,
'foo'
)
FROM information_schema.tables
WHERE table_schema = 'myschema'
然后返回:
ALTER TABLE my_db.my_schema.my_tableA OWNER TO foo;
ALTER TABLE my_db.my_schema.my_tableB OWNER TO foo;
ALTER TABLE my_db.my_schema.my_tableC OWNER TO foo;
成功
然后,当我运行select * from pg_tables; 时,我看到表所有者都没有改变。这怎么可能?会发生什么?
【问题讨论】:
-
你
commit;修改了吗? -
COMMIT 应该出现在语句的末尾吗?
-
在所有声明之后。
-
我刚刚收到警告:没有正在进行的事务提交
-
好的,那肯定是不一样的。
标签: sql postgresql ddl