1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith...

15
1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith [email protected]

Transcript of 1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith...

Page 1: 1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith raymond.smith@cgi.com.

1

Oracle Flashback Technologies

COUG Presentation – Feb 2010Feb 25, 2010

Ray Smith

[email protected]

Page 2: 1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith raymond.smith@cgi.com.

2

What are my objectives today?

Introduce you to some flashback technologies

Raise your awareness of what’s available

I won’t go over everything, 1 hour, not 5 days..

Maybe light a spark so you’ll go play too.

Fly through the slides as quickly as possible.

Go break my system and fix it… lots of times

Agenda:

Page 3: 1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith raymond.smith@cgi.com.

3

Flashback technologies

Flashback Query

Flashback Table

Flashback Drop

Flashback Versions Query

Flashback Transaction Query

Flashback Database

Flashback Data Archive

Page 4: 1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith raymond.smith@cgi.com.

4

Flashback technologies

Flashback Query SQL> exec dbms_flashback package.. 9i R1.

Scary code: DECLARE CURSOR emp_cur IS SELECT * FROM EMPLOYEE; v_rec emp_cur%rowtype; BEGINDBMS_FLASHBACK.ENABLE_AT_TIME ('25-FEB-10 08:10:58');open emp_cur;DBMS_FLASHBACK.DISABLE;

LOOPfetch emp_cur into v_rec;

EXIT WHEN emp_cur%NOTFOUND; INSERT INTO EMPLOYEE_TEMP VALUES (v_rec.emp_id, v_rec.name, v_rec.age ); END LOOP; close emp_cur; COMMIT; END;

SQL> SELECT .. FROM.. AS OF…. WHERE

Page 5: 1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith raymond.smith@cgi.com.

5

Flashback technologies

Flashback Table SQL> flashback table … to timestamp …

SQL> flashback table … to SCN …

Flashback Drop Use of Recyclebin

flashback table … to before drop;

Page 6: 1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith raymond.smith@cgi.com.

6

Flashback technologies

Flashback Versions Query Ability to capture changes to data over a given time.

VERSIONS_STARTTIME (start timestamp of version);

VERSIONS_STARTSCN (start SCN of version);

VERSIONS_ENDTIME (end timestamp of version);

VERSIONS_ENDSCN (end SCN of version);

VERSIONS_XID (transaction ID of version); and

VERSIONS_OPERATION (DML operation of version).

Page 7: 1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith raymond.smith@cgi.com.

7

Flashback technologies

Flashback Transaction Query Who run that? What was it? What is the UNDO code?

Use of FLASHBACK_TRANSACTION_QUERY

SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

SQL> select * from FLASHBACK_TRANSACTION_QUERY where xid= HEXTORAW('0003001A0000010D');

Page 8: 1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith raymond.smith@cgi.com.

8

Flashback technologies

Flashback Database – through RESETLOGS (10.2) Create a flash recovery area

Restart database ( mount exclusive )

SQL> ALTER DATASE FLASHBACK ON;

SQL> ALTER SYSTEM SET db_flashback_retention_target = <number_of_minutes>;

SQL> ALTER DATABASE OPEN;

Restore Points create restore point PREQA_TESTING;

create restore point PREQA_TESTING guarantee flashback database;

drop restore point PREQA_TESTING;

Page 9: 1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith raymond.smith@cgi.com.

9

Flashback technologies

Flashback Data Archive SQL> create FLASHBACK ARCHIVE default <flasharea>

tablespace <flash_tablespace> quota 200M retention 1 MONTH;

SQL> alter table <table> flashback archive <flasharea>;

Page 10: 1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith raymond.smith@cgi.com.

10

Why are DBA’s avoiding using Flashback options?

Complicated to setup – I think..

Too confusing.. I don’t have time to figure it out

It slows down my system.. I think

It’s new, so probably not so reliable

Page 11: 1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith raymond.smith@cgi.com.

11

Why DBA’s should get to know it…

It’s actually quite good.

It can seriously save your bacon.

Fast recoveries

Page 12: 1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith raymond.smith@cgi.com.

12

How do you configure Flashback?

It Depends.. Flashback Query – no setup required – Just undo

Flashback Table – no setup required – Just undo

Flashback Drop – Recyclebin – on by default.

Flashback Versions - no setup required – Just undo

Flashback Database – Requires a flash recovery area / feature to be switched on.

Flashback Transaction – may require supplimental data

Flashback Data Archives – needs flashback tablespace

Page 13: 1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith raymond.smith@cgi.com.

13

How to Flashback Database?

FLASHBACK DATABASE TO [BEFORE] SCN <system_change_number>

FLASHBACK DATABASE TO [BEFORE] TIMESTAMP <system_timestamp_value>

FLASHBACK DATABASE TO [BEFORE] RESTORE POINT <restore_point_name>

Page 14: 1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith raymond.smith@cgi.com.

14

Live Demo

Page 15: 1 Oracle Flashback Technologies COUG Presentation – Feb 2010 Feb 25, 2010 Ray Smith raymond.smith@cgi.com.

15

Summary

Start playing with flashback.

Potential issues ERROR at line 1:

ORA-08185: Flashback not supported for user SYS