Last active
August 29, 2015 14:06
-
-
Save yujihamaguchi/82d93dd6cd23f6a35ab1 to your computer and use it in GitHub Desktop.
[Redshift] テーブルの最終DML時間取得
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
MAX(endtime) + INTERVAL '9 hour' AS last_query_time | |
FROM | |
stl_query r1 | |
WHERE | |
EXISTS (SELECT * | |
FROM | |
stl_querytext r2 | |
WHERE | |
r1.userid = r2.userid | |
AND r1.query = r2.query | |
AND r1.xid = r2.xid | |
AND r1.pid = r2.pid | |
AND r2.text LIKE '%{table name}%') | |
; | |
-- クエリの内容を確認 | |
SELECT * | |
FROM | |
stl_querytext | |
WHERE | |
text LIKE '%{table name}%' | |
ORDER BY | |
1,2,3,4,5 | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment