How do I get the last accessed time stamp for the table in the snowflake?

霸气de小男生 提交于 2020-04-07 06:42:07

问题


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


回答1:


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%';


来源:https://stackoverflow.com/questions/60757699/how-do-i-get-the-last-accessed-time-stamp-for-the-table-in-the-snowflake

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!