Skip to content

Instantly share code, notes, and snippets.

@yujihamaguchi
Last active August 29, 2015 14:06
Show Gist options
  • Save yujihamaguchi/82d93dd6cd23f6a35ab1 to your computer and use it in GitHub Desktop.
Save yujihamaguchi/82d93dd6cd23f6a35ab1 to your computer and use it in GitHub Desktop.
[Redshift] テーブルの最終DML時間取得
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