0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Oracle Databaseで以前の値に戻すSQL

Posted at

where句を忘れた、指定をミスった、しかもコミットまでしちゃった!というときにデータを戻すためのSQL(フラッシュバッククエリ)です。

TARGET_TBLテーブルのtarget_columnを20分前の値に戻すSQL

update TARGET_TBL target 
set
    target_column = ( 
        select
            target_column 
        from
            TARGET_TBL as of timestamp (systimestamp - interval '20' minute) 
        where
            target.key_column = TARGET_TBL.key_column
    )

直接参照日時のtimestampを指定してもOK
as of timestamp to_timestamp('2021-11-21 09:30:00', 'YYYY-MM-DD HH:MI:SS')

Link

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?