How to restore the previous data after the Oracle database is updated or deleted

background

Now there is a user table t_userwith three fields, id, name, sex.

id name sex
1 Zhang San male

Executed the update statement and 张三changed it to 李四(just a simple simulation here, don't laugh), and then we want to see what his previous name was

View data before updating or deleting

The code is directly written here, which is very simple. The code to view the data in the table three minutes ago is as follows:

select * from  t_user  AS OF TIMESTAMP SYSDATE-3/1440  where id = '1'

The result is as follows:

id name sex
1 Zhang San male

Here is the explanation of sql:

SYSDATE : current time

1440 :24h*60m=1440m

3: 3 minutes ago

It should be noted here that do not use aliases, an error will be reported.

We have been able to query his previous data, and it is not difficult to change it back, so I will not introduce it here.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324437627&siteId=291194637
Recommended