Você está na página 1de 30

6

Flashback
Copyright 2008, Oracle. All rights reserved.

Objectives

$ecycle bin Flashback D( Config) F( D( !onitor F( D( *uar) $es) t)

After completing this lesson, you should be able to: Query the recycle bin Configure Flashback Database erform Flashback Database to a point in time !onitor flashback log statistics "nable and disable the Flashback Database feature #se the "nterprise !anager $ecovery %i&ard to perform Flashback Database #se guaranteed restore points 'ith Flashback Database

6-2

Copyright 2008, Oracle. All rights reserved.

Flashback +echnology: $evie'


Object evel!ce"ario #$a%ples +atabase &lashbac' (ech"ology )ses A**ects +ata

(r,"cate table- )"desired +atabase %,ltitable cha"ges %ade +rop table )pdate /ith the /ro"g WHERE cla,se +rop (able

&lashbac' logs(.)#

(able

.ecycle bi" )"do data )"do data )"do data )"do data

(.)# (.)# &A !# &A !# &A !#

Co%pare c,rre"t data /ith 0,ery data *ro% the past Co%pare versio"s o* a ro/ 1ersio" ($ 2"vestigate several historical states o* data (ra"sactio"

6-3

Copyright 2008, Oracle. All rights reserved.

Flashback Drop and the $ecycle (in


RECYCLEBIN=ON

DROP TABLE employees;

FLASHBACK TABLE employees TO BEFORE DROP;

!istake 'as made)

6-3

Copyright 2008, Oracle. All rights reserved.

$ecycle (in
BIN$zbj B'p#==$$ BIN$zbj !"#y==$$ (SER&OB)ECTS / DBA&FREE&SPACE E%PLOYEES , E%PLOYEES&PK Objects are: 5 $enamed 5 0ot moved BIN$zbj !"#y==$$ BIN$zbj B'p#==$$ E%PLOYEES E%PLOYEES&PK

$ecycle bin

DROP TABLE employees;


Copyright 2008, Oracle. All rights reserved.

6-4

.ecycle 6i" 7"otes o"ly slide8

6-6

Copyright 2008, Oracle. All rights reserved.

$estoring +ables from the $ecycle (in


$estore dropped tables and dependent objects) 1f multiple recycle bin entries have the same original name:
5 #se uni2ue, system3generated names to restore a particular version 5 %hen using original names, the restored table is last in, first out 451FO6

$ename the original name if that name is currently used)


FLASHBACK TABLE *+!ble&,!meTO BEFORE DROP .RENA%E TO *,e#&,!me-/;

6-9

Copyright 2008, Oracle. All rights reserved.

$ecycle (in: Automatic 7pace $eclamation


$ecycle bin BIN$zbj B'p#==$$ BIN$zbj !"#y==$$

BIN$zbj B'p#==$$ BIN$zbj !"#y==$$

DBA&FREE&SPACE 0 RECYCLEBIN

Autoe8tend ,

6-8

Copyright 2008, Oracle. All rights reserved.

.ecycle 6i"; A,to%atic !pace .ecla%atio" 7"otes o"ly slide8

6-:

Copyright 2008, Oracle. All rights reserved.

$ecycle (in: !anual 7pace $eclamation


P(R1E 2TABLE *+!ble&,!me-3INDE4 *5,'e6&,!me-7 P(R1E TABLESPACE *+s&,!me- .(SER *8se &,!me-/ P(R1E .(SER&3DBA&/RECYCLEBIN

6 - <0

Copyright 2008, Oracle. All rights reserved.

(ypassing the $ecycle (in

DROP TABLE *+!ble&,!me- .P(R1E/ ; DROP TABLESPACE *+s&,!me.INCL(DIN1 CONTENTS/ ; DROP (SER *8se &,!me- .CASCADE/ ;

6 - <<

Copyright 2008, Oracle. All rights reserved.

Querying the $ecycle (in

SELECT o#,e 9 o 5:5,!l&,!me9 obje;+&,!me9 +ype9 +s&,!me9 ' op+5me9 el!+e'9 sp!;e FRO% 'b!& e;y;leb5, <HERE ;!,&8,' op = =YES=; SELECT o 5:5,!l&,!me9 obje;+&,!me9 +ype9 +s&,!me9 ' op+5me9 el!+e'9 sp!;e FRO% 8se & e;y;leb5, <HERE ;!,&8,' op = =YES=; S>L- SHO< RECYCLEBIN

6 - <2

Copyright 2008, Oracle. All rights reserved.

Querying Data from Dropped +ables


(SER&TABLES
D$O "D +A(5":0A!"

NO YES YES NO
D$O "D

SALES BIN$zbj B'p#==$$ BIN$zbj !"#y==$$ SALES&PK


10D"9:0A!"

E%PLOYEES E%PLOYEES&PK

$ecycle bin

(SER&INDE4ES

SELECT ??? FRO% @BIN$zbj B'p#==$$@ .AS OF ???/ <HERE ???


6 - <3 Copyright 2008, Oracle. All rights reserved.

Flashback Database: $evie'

$ecycle bin > Flashback D( Config) F( D( !onitor F( D( *uar) $es) t)

+he Flashback Database operation: %orks like a re'ind button for the database Can be used in cases of logical data corruptions made by users

#sers generate errors)

+he database is corrupted)

=ou ;press the re'ind button)<

+he database is ;re'ound)<

6 - <3

Copyright 2008, Oracle. All rights reserved.

Flashback Database Architecture


7*A
Flashback buffer

0ot every changeA

(uffer cache

$edo log buffer

"very change 5og block before images periodically)

5*%$

Flashback logs

$?%$

$edo logs

. @

(ack out changes to database using before images)

Do for'ard media recovery)

6 - <4

Copyright 2008, Oracle. All rights reserved.

Configuring Flashback Database

$ecycle bin Flashback D( > Config) F( D( !onitor F( D( *uar) $es) t)

.) Configure the flash recovery area)

-) 7et the retention target)

,) "nable Flashback Database)

S>L- SH(TDO<N I%%EDIATE; S>L- START(P %O(NT E4CL(SIAE; S>L- ALTER SYSTE% SET B DB&FLASHBACK&RETENTION&TAR1ET=BCC$ SCOPE=BOTH; S>L- ALTER DATABASE FLASHBACK ON; S>L- ALTER DATABASE OPEN;
6 - <6 Copyright 2008, Oracle. All rights reserved.

Configuring Flashback Database #sing "!


!ake sure that the database is in ARCHIAELO1 mode)

6 - <9

Copyright 2008, Oracle. All rights reserved.

Configuring Flashback Database #sing "!


"nable flashback logging and specify the flash recovery area)

6 - <8

Copyright 2008, Oracle. All rights reserved.

Flashback Database: "8amples


R%AN- FLASHBACK DATABASE TO TI%E = B- @TO&DATED=B$$E0$F0BG HIJ$$J$$=9 K- =YYYY0%%0DD HHBEJ%IJSS=L@; R%AN- FLASHBACK DATABASE TO SCN=BKFIF; R%AN- FLASHBACK DATABASE B- TO SE>(ENCE=BBK THREAD=H; S>L- FLASHBACK DATABASE B TO TI%ESTA%PDSYSDATE0HMBEL; S>L- FLASHBACK DATABASE TO SCN FK"EK; S>L- FLASHBACK DATABASE TO RESTORE POINT bE&lo!';
6 - <: Copyright 2008, Oracle. All rights reserved.

erforming Flashback Database #sing "!


7elect object and operation type)

6 - 20

Copyright 2008, Oracle. All rights reserved.

erforming Flashback Database #sing "!


5aunching the $ecovery %i&ard:

6 - 2<

Copyright 2008, Oracle. All rights reserved.

erforming Flashback Database #sing "!

6 - 22

Copyright 2008, Oracle. All rights reserved.

Flashback Database Considerations


%hen the Flashback Database operation completes, open the database:
5 1n read3only mode to verify that the correct target time or 7C0 'as used 5 %ith a RESETLO1S operation to allo' for D!5

+he opposite of ;flash back< is ;recover)< =ou cannot use Flashback Database in the follo'ing situations:
5 +he control file has been restored or re3created) 5 A tablespace has been dropped) 5 A data file has been shrunk)

6 - 23

#se the TO BEFORE RESETLO1S to flash back to before the last RESETLO1S operation)
Copyright 2008, Oracle. All rights reserved.

&lashbac' +atabase Co"sideratio"s 7"otes o"ly slide8

6 - 23

Copyright 2008, Oracle. All rights reserved.

!onitoring Flashback Database

$ecycle bin Flashback D( Config) F( D( > !onitor F( D( *uar) $es) t)

+o monitor the ability to meet your retention target: ?ie' the flash recovery area disk 2uota:
S>L- SELECT es+5m!+e'&Nl!sOb!;P&s5ze9 B Nl!sOb!;P&s5ze K FRO% A$FLASHBACK&DATABASE&LO1;

Determine the current flashback 'indo':

S>L- SELECT ol'es+&Nl!sOb!;P&s;,9 B ol'es+&Nl!sOb!;P&+5me K FRO% A$FLASHBACK&DATABASE&LO1;

!onitor logging in the Flashback Database logs:

S>L- SELECT Q B FRO% A$FLASHBACK&DATABASE&STAT;


6 - 24 Copyright 2008, Oracle. All rights reserved.

=otes O"ly !lide

6 - 26

Copyright 2008, Oracle. All rights reserved.

!onitoring Flashback Database 'ith "!

6 - 29

Copyright 2008, Oracle. All rights reserved.

*uaranteed $estore oints

$ecycle bin Flashback D( Config) F( D( !onitor F( D( > *uar) $es) t)

A guaranteed restore point ensures that you can perform a FLASHBACK DATABASE command to that 7C0 at any time)

S>L- CREATE RESTORE POINT beNo e&lo!' B 1(ARANTEE FLASHBACK DATABASE;

6 - 28

Copyright 2008, Oracle. All rights reserved.

7ummary
1n this lesson, you should have learned ho' to: Query the recycle bin Configure Flashback Database erform Flashback Database to a point in time using "nterprise !anager or $!A0 !onitor flashback log statistics "nable and disable the Flashback Database feature #se guaranteed restore points 'ith Flashback Database

6 - 2:

Copyright 2008, Oracle. All rights reserved.

ractice Overvie': erforming Flashback Database


+his practice covers the follo'ing topics: erforming Flashback Database to undo un'anted transactions !onitoring the Flashback Database retention Determine the si&e of the flashback logs

6 - 30

Copyright 2008, Oracle. All rights reserved.

Você também pode gostar