我收到了 AWS Support 的回复。 tl;dr:alter table 可以由那些可以运行,并且只有那些可以删除 table 的人才能运行。
"""
这是因为,确定用户是否可以更改表的工作方式与确定给定用户是否可以删除表的方式类似。也就是说,只有表的所有者、模式所有者或超级用户才能更改表。根据我们的文档,“修改或销毁对象的权利始终只是所有者的特权。” [1]。
[1] 默认数据库用户权限 - https://docs.aws.amazon.com/redshift/latest/dg/r_Privileges.html
因此,要查看对特定表具有更改表权限的用户,需要通过运行以下命令来确定该特定表的所有者:
请注意,在此示例中,使用了“销售”表。您可以根据需要对其进行编辑。要查看所有表所有者,可以删除 WHERE 子句的 AND 部分。
====Query to see table owners====
SELECT n.nspname AS schema_name
, pg_get_userbyid(c.relowner) AS table_owner
, c.relname AS table_name
, CASE WHEN c.relkind = 'v' THEN 'view' ELSE 'table' END
AS table_type
, d.description AS table_description
FROM pg_class As c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace
LEFT JOIN pg_description As d
ON (d.objoid = c.oid AND d.objsubid = 0)
WHERE c.relkind IN('r', 'v')
AND c.relname = 'sales'
ORDER BY n.nspname, c.relname;
您还可以通过运行以下查询来查看所有有权更改表的超级用户:
====Query to see superusers====
SELECT usename FROM pg_user WHERE usesuper = 'true';
这两个结果的组合将使您能够查看所有具有更改表权限的用户。
"""