How do I get the last accessed time stamp for the

2020-04-30 02:18发布

I want to get the last accessed timestamp for a table in the snowflake

1条回答
你好瞎i
2楼-- · 2020-04-30 02:56

Not always ideal, but a quick way to find this for one-off questions is to use QUERY_HISTORY

SELECT START_TIME, * 
FROM TABLE(INFORMATION_SCHEMA.QUERY_HISTORY()) 
WHERE QUERY_TEXT LIKE '%MYSCHEMA.MYTABLE%';

Update: Query to specifically get just the most recent query time. Have to filter out the QUERY_HISTORY queries themselves. This is not especailly fast, and does require that the role that's running this has access to all the relevant history.

SELECT MAX(START_TIME)
FROM TABLE(INFORMATION_SCHEMA.QUERY_HISTORY()) 
WHERE QUERY_TEXT ILIKE '%CONFIG.PIPELINE_LOG%'
AND NOT QUERY_TEXT ILIKE '%INFORMATION_SCHEMA.QUERY_HISTORY%';
查看更多
登录 后发表回答