oracle 11g 闪回功能,Oracle 11g 高效灵活的闪回数据库功能

本文展示了在一个运行于归档模式并启用闪回日志的Oracle数据库中,如何进行闪回和恢复操作。通过创建多个还原点,删除不同职位的员工记录,然后分别闪回到不同的还原点,展示向回和向前的闪回能力。恢复操作通过RMAN执行,确保数据一致性。实验验证了数据库能够在多个时间点间灵活地进行闪回。
摘要由CSDN通过智能技术生成

--运行于归档模式且打开闪回日志的数据库,可以进行任意方向的闪回(向回或向前)

1stzvad9nU5AAAAAElFTkSuQmCC

--查看数据库运行在归档模式

sys@TESTDB11>archiveloglist;

DatabaselogmodeArchiveMode

Automatic archivalEnabled

Archive destination/archive2

Oldestonlinelogsequence97

Nextlogsequencetoarchive99

Currentlogsequence99

--开启闪回日志

sys@TESTDB11>alterdatabase

flashbackon;

Database altered.

--创建表

scott@TESTDB11>createtableemp1asselect*fromemp;

Tablecreated.

--创建还原点并删除数据

scott@TESTDB11>createrestore

point rp_bd_analyst;

Restore point created.

--删除analyst

scott@TESTDB11>deletefromemp1wherejob='ANALYST';

2rowsdeleted.

--删除clerk

scott@TESTDB11>createrestore

point rp_bd_clerk;

Restore point created.

scott@TESTDB11>deletefromemp1wherejob='CLERK';

4rowsdeleted.

--删除manager

scott@TESTDB11>createrestore

point rp_bd_manager;

Restore point created.

scott@TESTDB11>deletefromemp1wherejob='MANAGER';

3rowsdeleted.

--删除president

scott@TESTDB11>createrestore

point rp_bd_president;

Restore point created.

scott@TESTDB11>deletefromemp1wherejob='PRESIDENT';

1rowdeleted.

sys@TESTDB11>shutdownimmediate;

idle>startup mount;

ORACLE instance started.

Total SystemGlobalArea855982080bytes

FixedSize2230792bytes

VariableSize645924344bytes

Database Buffers205520896bytes

Redo Buffers2306048bytes

Database mounted.

--闪回到第2个还原点

idle>flashback databasetorestore point rp_bd_clerk;

Flashback complete.

idle>alterdatabaseopenreadonly;

Database altered.

idle>conn scott/scott

Connected.

scott@TESTDB11>select*fromemp1;

EMPNO ENAMEJOBMGR HIREDATESALCOMMDEPTNO

---------- ---------- --------- ---------- --------- ----------

---------- ----------

7369SMITHCLERK790217-DEC-8080020

7499ALLENSALESMAN769820-FEB-81160030030

7521WARDSALESMAN769822-FEB-81125050030

7566JONESMANAGER783902-APR-81297520

7654MARTINSALESMAN769828-SEP-811250140030

7698BLAKEMANAGER783901-MAY-81285030

7782CLARKMANAGER783909-JUN-81245010

7839KINGPRESIDENT17-NOV-81500010

7844TURNERSALESMAN769808-SEP-811500030

7876ADAMSCLERK778823-MAY-87110020

7900JAMESCLERK769803-DEC-8195030

7934MILLERCLERK778223-JAN-82130010

12rowsselected.

scott@TESTDB11>select*fromemp1orderbyjob;

EMPNO ENAMEJOBMGR HIREDATESALCOMMDEPTNO

---------- ---------- --------- ---------- --------- ----------

---------- ----------

7934MILLERCLERK778223-JAN-82130010

7900JAMESCLERK769803-DEC-8195030

7876ADAMSCLERK778823-MAY-87110020

7369SMITHCLERK790217-DEC-8080020

7566JONESMANAGER783902-APR-81297520

7698BLAKEMANAGER783901-MAY-81285030

7782CLARKMANAGER783909-JUN-81245010

7839KINGPRESIDENT17-NOV-81500010

7844TURNERSALESMAN769808-SEP-811500030

7521WARDSALESMAN769822-FEB-81125050030

7499ALLENSALESMAN769820-FEB-81160030030

7654MARTINSALESMAN769828-SEP-811250140030

12rowsselected.

scott@TESTDB11>conn/assysdba

Connected.

sys@TESTDB11>shutdownimmediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

sys@TESTDB11>startup mount;

ORACLE instance started.

Total SystemGlobalArea855982080bytes

FixedSize2230792bytes

VariableSize645924344bytes

Database Buffers205520896bytes

Redo Buffers2306048bytes

Database mounted.

--闪回到第1个还原点

sys@TESTDB11>flashback databasetorestore point rp_bd_analyst;

Flashback complete.

sys@TESTDB11>alterdatabaseopenreadonly;

Database altered.

sys@TESTDB11>select*fromscott.emp1orderbyjob;

EMPNO ENAMEJOBMGR HIREDATESALCOMMDEPTNO

---------- ---------- --------- ---------- --------- ----------

---------- ----------

7788SCOTT ANALYST756619-APR-87300020

7902FORDANALYST756603-DEC-81300020

7934MILLERCLERK778223-JAN-82130010

7900JAMESCLERK769803-DEC-8195030

7369SMITHCLERK790217-DEC-8080020

7876ADAMSCLERK778823-MAY-87110020

7698BLAKEMANAGER783901-MAY-81285030

7566JONESMANAGER783902-APR-81297520

7782CLARKMANAGER783909-JUN-81245010

7839KINGPRESIDENT17-NOV-81500010

7844TURNERSALESMAN769808-SEP-811500030

7654MARTINSALESMAN769828-SEP-811250140030

7521WARDSALESMAN769822-FEB-81125050030

7499ALLENSALESMAN769820-FEB-81160030030

14rowsselected.

sys@TESTDB11>shutdownimmediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

sys@TESTDB11>startup mount;

ORACLE instance started.

Total SystemGlobalArea855982080bytes

FixedSize2230792bytes

VariableSize645924344bytes

Database Buffers205520896bytes

Redo Buffers2306048bytes

Database mounted.

--闪回到第4个还原点

sys@TESTDB11>flashback databasetorestore point rp_bd_president;

Flashback complete.

sys@TESTDB11>alterdatabaseopenreadonly;

Database altered.

sys@TESTDB11>select*fromscott.emp1orderbyjob;

EMPNO ENAMEJOBMGR HIREDATESALCOMMDEPTNO

---------- ---------- --------- ---------- --------- ----------

---------- ----------

7839KINGPRESIDENT17-NOV-81500010

7521WARDSALESMAN769822-FEB-81125050030

7844TURNERSALESMAN769808-SEP-811500030

7499ALLENSALESMAN769820-FEB-81160030030

7654MARTINSALESMAN769828-SEP-811250140030

sys@TESTDB11>shutdownimmediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

sys@TESTDB11>startup mount;

ORACLE instance started.

Total SystemGlobalArea855982080bytes

FixedSize2230792bytes

VariableSize645924344bytes

Database Buffers205520896bytes

Redo Buffers2306048bytes

Database mounted.

--闪回到第3个还原点

sys@TESTDB11>flashback databasetorestore point rp_bd_manager;

Flashback complete.

sys@TESTDB11>alterdatabaseopenreadonly;

Database altered.

sys@TESTDB11>select*fromscott.emp1orderbyjob;

EMPNO ENAMEJOBMGR HIREDATESALCOMMDEPTNO

---------- ---------- --------- ---------- --------- ----------

---------- ----------

7782CLARKMANAGER783909-JUN-81245010

7698BLAKEMANAGER783901-MAY-81285030

7566JONESMANAGER783902-APR-81297520

7839KINGPRESIDENT17-NOV-81500010

7844TURNERSALESMAN769808-SEP-811500030

7521WARDSALESMAN769822-FEB-81125050030

7499ALLENSALESMAN769820-FEB-81160030030

7654MARTINSALESMAN769828-SEP-811250140030

8rowsselected.

sys@TESTDB11>shutdownimmediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

--恢复到第4个还原点

sys@TESTDB11>startup mount;

ORACLE instance started.

Total SystemGlobalArea855982080bytes

FixedSize2230792bytes

VariableSize645924344bytes

Database Buffers205520896bytes

Redo Buffers2306048bytes

Database mounted.

--在rman中执行recover

RMAN>recover databasetorestore point rp_bd_president;

Starting recoverat25-FEB-14

usingtarget database controlfileinsteadofrecoverycatalog

allocated channel:ORA_DISK_1

channel ORA_DISK_1:SID=21devicetype=DISK

starting media recovery

media recovery complete,elapsedtime:00:00:01

Finished recoverat25-FEB-14

sys@TESTDB11>alterdatabaseopenreadonly;

Database altered.

sys@TESTDB11>select*fromscott.emp1orderbyjob;

EMPNO ENAMEJOBMGR HIREDATESALCOMMDEPTNO

---------- ---------- --------- ---------- --------- ----------

---------- ----------

7839KINGPRESIDENT17-NOV-81500010

7521WARDSALESMAN769822-FEB-81125050030

7844TURNERSALESMAN769808-SEP-811500030

7499ALLENSALESMAN769820-FEB-81160030030

7654MARTINSALESMAN769828-SEP-811250140030

--结论:可以向回,也可以向前来回进行闪回操作.向前闪回等价于recover操作

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值