如何查找在Snowflake中创建表的用户

sam*_*ann 0 snowflake-cloud-data-platform

我试图在雪花中找到由用户创建的表。Information_Schema表仅显示拥有它的角色。

遍历Query_History是费力的。

谢谢山姆

Information_Schema和显示表命令。

Ric*_*ane 5

在Snowflare.account_usage.query_history中随机搜索可能会很费力,但针对性搜索相当快速简便,这应该对您有用。

SET dbName='DATABASE NAME HERE';
SET schemaName='SCHEMA NAME HERE';
SET tableName='TABLE NAME HERE';
SET create_dt=(
    SELECT MIN(created) 
    FROM snowflake.account_usage.tables 
    WHERE table_catalog = $dbName 
    AND table_schema = $schemaName 
    AND table_name = $tableName 
    AND deleted is null);

SELECT  * 
FROM   snowflake.account_usage.query_history
WHERE  query_text iLike '%CREATE%TABLE%'||$tableName||'%'
AND    execution_status = 'SUCCESS'
AND    start_time = $create_dt;
Run Code Online (Sandbox Code Playgroud)