【问题标题】:Need to identify the user, not role, that created a table需要识别创建表的用户,而不是角色
【发布时间】:2020-11-05 17:09:31
【问题描述】:

我正在尝试将对象(表)关联回创建它的用户。由于对象归活动角色所有,我如何获取单个用户创建的表列表?我在 QUERY_HISTORY 中搜索了 create table 语句,但正在寻找更好的解决方案。

【问题讨论】:

  • 我相信唯一的解决方案是查看QUERY_HISTORY

标签: snowflake-cloud-data-platform


【解决方案1】:

这样的事情有帮助吗?或者这就是你现在正在做的事情?我认为这是目前可用的主要解决方案。当然,您可以根据需要更改过滤器,包括按特定用户或时间范围进行过滤。

use role accountadmin;
use schema snowflake.account_usage;
select q.start_time created_time, q.user_name, t.table_name, q.query_text, t.table_schema schemas_name, T.table_catalog database_name from query_history q
inner join tables t 
on q.start_time = t.created
and q.schema_name = t.table_schema
and q.database_name = t.table_catalog
and q.query_text ilike 'create%table%'
and q.start_time > '2020-11-04 11:13:54'
order by q.start_time;

【讨论】:

  • 为该 create table 语句添加角色名称将回答这个问题。
【解决方案2】:

你应该可以用这样的查询来做到这一点

use schema snowflake.account_usage;    
select *
    from QUERY_HISTORY
    where 
    database_name = 'TPCDS'
    and query_type = 'CREATE'
    ;

【讨论】:

    猜你喜欢
    • 2017-08-10
    • 1970-01-01
    • 2020-12-11
    • 2021-03-09
    • 1970-01-01
    • 1970-01-01
    • 2016-09-09
    • 2015-10-08
    • 2018-08-07
    相关资源
    最近更新 更多