Skip to content

Commit

Permalink
发布博客,时间:2023-12-12 23:14:36
Browse files Browse the repository at this point in the history
  • Loading branch information
whp98 committed Dec 12, 2023
1 parent cdbd2cd commit 2cbd18e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
53 changes: 53 additions & 0 deletions docs/数据库/Oracle数据库/Oracle数据库恢复.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Oracle数据库恢复

原文 https://blog.csdn.net/u011595939/article/details/80052810



## 查询指定时间的数据快照

```SQL
-- 1、查询执行过SQL语句,确定快照的时间
SELECT R.FIRST_LOAD_TIME,R.SQL_TEXT,R.* FROM V$SQLAREA R
WHERE R.SQL_TEXT LIKE '%ABOUT YOUR SQL%' ORDER BY R.FIRST_LOAD_TIME DESC
```

```SQL
-- 2、查询基于指定时间的数据快照
SELECT * FROM YOUR_TABLENAME AS OF TIMESTAMP
TO_TIMESTAMP('2019-02-05 20:00:00', 'yyyy-mm-dd hh24:mi:ss');
```

```SQL
-- 以当前时间为准,125分钟之前的数据快照
SELECT * FROM YOUR_TABLENAME AS OF TIMESTAMP SYSDATE - 125 / 1440
```

## 恢复数据

>FLASHBACK时,如果不确定删除的具体时间,在没有太多操作这个表的情况下,闪回的时间稍微提前一点。
闪回表数据SQL语句:

```SQL
-- 1、启动表的row movement特性
ALTER TABLE YOUR_TABLENAME ENABLE ROW MOVEMENT;
```


```SQL
-- 2、闪回指定时间的快照
FLASHBACK TABLE YOUR_TABLENAME TO TIMESTAMP
TO_TIMESTAMP('2018-04-23 16:06:00','yyyy-mm-dd hh24:mi:ss');
```


```SQL
-- 3、关闭表的row movement功能
ALTER TABLE YOUR_TABLENAME DISABLE ROW MOVEMENT;
```

闪回数据表的SQL语句:
```SQL
-- 闪回表(通过TRUNCATE语句删除的表无法闪回)
FLASHBACK TABLE YOUR_TABLENAME TO BEFORE DROP;```
1 change: 1 addition & 0 deletions docs/数据库/Oracle数据库/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- [linux服务器上修改oracle数据库的字符集](./linux服务器上修改oracle数据库的字符集.md)
- [Oracle数据库乱码](./Oracle数据库乱码解决.md)
- [Oracle数据库导入 impdp](./Oracle数据库导入impdp.md)
- [Oracle数据库恢复](./Oracle数据库恢复.md)
- [Oracle脚本注意事项](./Oracle脚本注意事项.md)
- [Oracle表结构导出](./Oracle表结构导出.md)
- [ 虚拟机 oracle linux 7.9 安装ORACLE 19c ](./虚拟机oracleLinux7.9安装ORACLE19c.md)

0 comments on commit 2cbd18e

Please sign in to comment.