Redshift视图定义权限问题

时间:2020-04-08 14:43:28

标签: amazon-redshift

即使使用postgres登录名运行此查询,也仅针对由当前登录名创建的视图显示view_definition。

select table_schema as schema_name, table_name as view_name, view_definition from information_schema.views where table_schema not in ('information_schema', 'pg_catalog') order by schema_name, view_name;

是否有某种方法可以获取所有视图的视图定义,无论是谁创建的?

如果不是这样,我计划只在我的etl调度程序中工作,以将所有视图重新分配给所有者postgres。

1 个答案:

答案 0 :(得分:2)

如果当前用户(甚至admin)不是视图的所有者,则View_definition的Information_schema.views返回NULL [1]。这是它在Postgres中的设计方式,并且由于Redshift基于Postgres 8.0.2,因此我认为它具有类似的行为。

AWS的GitHub存储库中的v_generate_view_ddl [2]管理员视图可以帮助获取所有视图定义。

参考文献:
[1] Postgres文档-https://www.postgresql.org/docs/8.0/infoschema-views.html
[2] Redshift管理员视图-https://github.com/awslabs/amazon-redshift-utils/blob/master/src/AdminViews/v_generate_view_ddl.sql