SlideShare une entreprise Scribd logo
1  sur  249
Télécharger pour lire hors ligne
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
2
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
3
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Stuff
youtube bit.ly/youtube-connor
blog bit.ly/blog-connor
twitter bit.ly/twitter-connor
400+ posts mainly on database & development
250 technical videos, new uploads every week
rants and raves on tech and the world :-)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
etc...
facebook bit.ly/facebook-connor
linkedin bit.ly/linkedin-connor
instagram bit.ly/instagram-connor
slideshare bit.ly/slideshare-connor
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
https://asktom.oracle.com
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
7https://asktom.oracle.com/officehours
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
Flashback - the forgotten feature
Connor McDonald
Database Advocate
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback
11
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
several technologies
12
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback query
flashback table
flashback drop
flashback database
flashback transaction
flashback data archive
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback
query
14
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
controversy
15
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
you have always...
16
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
.. been using flashback query
17
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
revision
18
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> update EMP
2 set SAL = SAL * 1.10
3 /
14 rows updated.
SQL> rollback;
Rollback complete.
how ?
19
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
we remember stuff
20
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> update EMP
2 set SAL = SAL * 1.10
3 /
undo header
smith $1,0001
block 2754
jones $9002
brown $1,5003
wells $2,0004
wilson $1,0005
block 2754, row 1,
sal $1000
block 2754, row 2,
sal $900
block 2754, row 3,
sal $1500
block 2754, row 4,
sal $2000
uba 5
5
$1,100
$990
$1,650
$2,200
uba 5.1uba 5.2
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> rollback;
22
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> rollback;
undo header
smith $1,0001
block 2754
jones $9002
brown $1,5003
wells $2,0004
wilson $1,0005
block 2754, row 1,
sal $1000
block 2754, row 2,
sal $900
block 2754, row 3,
sal $1500
block 2754, row 4,
sal $2000
uba 5
5
$1,100
$990
$1,650
$2,200
uba 5.1uba 5.2
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
we can use this stuff for queries!
(Oracle version 4)
24
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
read consistency
25
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
select * from emp
where hiredate > '01/01/2004'
update emp set …
where empno = 1234;
Block 3217
"I need block 3217…
… as it was at 9:00"
9:00
9:03
9:05
session 1 session 2
...and time = scn
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
system change number
27
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
Session 1
Request
Block 3217,
SCN 4567192
Block 3217,
SCN 4567234
"ABC" Block 3217,
SCN 4567003,
change ABC => XYZ
undo segment block(s)
No good..too new
take a copy of the block
Locate
apply undo
Block 3217,
SCN 4567234
"ABC"
Block 3217,
SCN 4567234
"ABC"
Block 3217,
SCN 4567003
"XYZ"
Block 3217,
SCN 4567003
"XYZ"
Session 2
update emp
set ename = "ABC"
where empno = 1234;
commit;
Done !
28
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
every query = locked at a SCN
29
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
30
go back even further....
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback query = choose SCN
31
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
v9
32
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select * from DEPT;
DEPTNO DNAME LOC
---------- -------------- -------------
10 UNKNOWN NEW YORK
20 UNKNOWN DALLAS
30 UNKNOWN CHICAGO
40 UNKNOWN BOSTON
33
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select * from DEPT AS OF SCN 995401;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
34
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
a little less geeky
35
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select * from DEPT
2 AS OF TIMESTAMP systimestamp -
3 interval '20:00' minute to second;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
36
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
smon_scn_time
37
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
smon_scn_time ???
38
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
obsolete*
39
more later on this
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select TIMESTAMP_TO_SCN(systimestamp) from DUAL;
TIMESTAMP_TO_SCN(SYSTIMESTAMP)
------------------------------
998332
40
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select SCN_TO_TIMESTAMP(998314) from DUAL;
SCN_TO_TIMESTAMP(998314)
-----------------------------------------------
25-FEB-19 09.12.48.000000000 PM
41
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
3 seconds
42
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select scn_to_timestamp(2409511-rownum)
2 from dual
3 connect by level <= 50;
SCN_TO_TIMESTAMP(2409511-ROWNUM)
---------------------------------------------
28-FEB-19 05.47.47.000000000 PM
28-FEB-19 05.47.47.000000000 PM
28-FEB-19 05.47.44.000000000 PM
28-FEB-19 05.47.41.000000000 PM
28-FEB-19 05.47.37.000000000 PM
28-FEB-19 05.47.34.000000000 PM
28-FEB-19 05.47.31.000000000 PM
28-FEB-19 05.47.28.000000000 PM
28-FEB-19 05.47.25.000000000 PM
43
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
use in "normal" queries
44
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select e.empno, e.ename, d.dname
2 from emp e,
3 dept AS OF TIMESTAMP '23-FEB-19 11.51.02 PM' d
3 where d.deptno = e.deptno;
EMPNO ENAME DNAME
---------- ---------- --------------
7782 CLARK "PREVIOUS NAME"
7839 KING "PREVIOUS NAME"
7934 MILLER "PREVIOUS NAME"
7566 JONES RESEARCH
7902 FORD RESEARCH
7876 ADAMS RESEARCH
7369 SMITH RESEARCH
7788 SCOTT RESEARCH
45
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
"What's in it for me?"
46
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
1) unit testing
47
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select case
2 when d1.deptno is null then 'DELETE'
3 when d2.deptno is null then 'INSERT'
4 end action,
5 d1.deptno, d2.deptno, d1.dname, d1.loc
6 from DEPT d1 full outer join
7 DEPT AS OF TIMESTAMP '23-FEB-19 11.51.02 PM' d2
8 on d1.deptno = d2.deptno;
ACTION DEPTNO DEPTNO DNAME LOC
------ ---------- ---------- -------------- ----------
10 10 ACCOUNTING NEW YORK
20 20 RESEARCH DALLAS
30 30 SALES CHICAGO
DELETE 40
INSERT 50 MARKETING PERTH
48
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
2) not just your data
49
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> drop procedure debug_msg;
Procedure dropped.
SQL> connect / as sysdba
Connected.
SQL> select text
2 from dba_source
3 as of timestamp systimestamp - interval '5' minute
4 where name='DEBUG_MSG' order by line;
TEXT
---------------------------------------------------------------------
procedure debug_msg(m varchar2) is
begin
dbms_output.put_line(m);
dbms_application_info.set_client_info(m);
end;
5 rows selected.
50
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
3) functional diagnosis
51
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select * from DEPT;
DEPTNO DNAME LOC
---------- -------------- -------------
10 UNKNOWN NEW YORK
SQL> select * from DEPT
2 as of TIMESTAMP SYSTIMESTAMP -
3 INTERVAL '20:00' MINUTE TO SECOND;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
1 change ?
10 changes ?
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback row versions
53
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> SELECT deptno, dname
2 FROM dept
3 VERSIONS BETWEEN
4 TIMESTAMP SYSTIMESTAMP –
5 INTERVAL '20:00' MINUTE TO SECOND
6 AND SYSTIMESTAMP
7 WHERE deptno = 10;
DEPTNO DNAME
---------- --------------
10 ACCOUNTING
10 MONEY GRABBERS
10 FINANCE
10 BEAN COUNTERS
10 UNKNOWN
1 row
5 versions
54
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
versions_starttime
versions_startscn
versions_endtime
versions_endscn
versions_xid
versions_operation
55
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> SELECT deptno, dname,
2 VERSIONS_STARTTIME
3 ,VERSIONS_XID
4 ,VERSIONS_OPERATION
5 FROM dept
6 VERSIONS BETWEEN
7 TIMESTAMP SYSTIMESTAMP - INTERVAL '20:00' MINUTE TO SECOND
8 AND SYSTIMESTAMP
9 WHERE deptno = 10;
DEPTNO DNAME VERSIONS_STARTTIME VERSIONS_XID V
---------- -------------- ------------------------ ---------------- -
10 UNKNOWN 03-SEP-18 11.53.45 PM 0200100060040000 U
10 MONEY GRABBERS 03-SEP-18 11.53.36 PM 0600050065040000 U
10 FINANCE 03-SEP-18 11.53.24 PM 09000D001D050000 U
10 BEAN COUNTERS 03-SEP-18 11.53.12 PM 01001A00EA030000 U
10 ACCOUNTING
56
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
get the lot ...
57
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> SELECT deptno, dname,
2 VERSIONS_STARTTIME
3 ,VERSIONS_XID
4 ,VERSIONS_OPERATION
5 FROM dept VERSIONS BETWEEN SCN MINVALUE AND MAXVALUE;
DEPTNO DNAME VERSIONS_STARTTIME VERSIONS_XID V
---------- -------------- ------------------------ ---------------- -
50 UNKNOWN 03-SEP-18 11.08.15 PM 04000700EA030000 U
30 UNKNOWN 03-SEP-18 11.08.15 PM 04000700EA030000 U
20 NERDS 03-SEP-18 11.07.57 PM 090016001D050000 U
20 R&D 03-SEP-18 11.07.48 PM 05000B0074040000 U
...
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
grant flashback to ...
59
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
session level
60
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
dbms_flashback.enable_at_time(systimestamp-1);
61
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> exec dbms_flashback.enable_at_time(
systimestamp-5/86400)
PL/SQL procedure successfully completed.
SQL> insert into T values (1);
ERROR at line 1:
ORA-08182:
operation not supported while in Flashback mode
62
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> exec dbms_flashback.disable;
PL/SQL procedure successfully completed.
SQL> exec dbms_flashback.enable_at_time(
systimestamp-30/86400)
PL/SQL procedure successfully completed.
SQL> exec dbms_flashback.enable_at_time(
systimestamp-60/86400)
ERROR at line 1:
ORA-08184: attempting to re-enable Flashback while in Flashback
63
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
just how far ?
64
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
undo_retention
65
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> show parameter undo_retention
NAME TYPE VALUE
------------------------------ ----------- --------
undo_retention integer 900
66
~
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> desc v$undostat
Name Null? Type
----------------------------- -------- ----------------
BEGIN_TIME DATE
END_TIME DATE
...
...
TUNED_UNDORETENTION NUMBER
CON_ID NUMBER
67
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
much much further
flashback data archive
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
"no" spanning DDL
69
better each version
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
rewind the data, not time
70
charactersets,
NLS etc
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback
transaction
71
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> SELECT deptno, dname,
2 VERSIONS_STARTTIME
3 ,VERSIONS_XID
4 ,VERSIONS_OPERATION
5 FROM dept VERSIONS BETWEEN SCN MINVALUE AND MAXVALUE;
DEPTNO DNAME VERSIONS_STARTTIME VERSIONS_XID V
---------- -------------- ------------------------ ---------------- -
50 UNKNOWN 03-SEP-18 11.08.15 PM 04000700EA030000 U
30 UNKNOWN 03-SEP-18 11.08.15 PM 04000700EA030000 U
20 NERDS 03-SEP-18 11.07.57 PM 090016001D050000 U
20 R&D 03-SEP-18 11.07.48 PM 05000B0074040000 U
...
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
XID ?
73
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> desc V$TRANSACTION
Name Null? Type
----------------------------- -------- -------
XIDUSN NUMBER
XIDSLOT NUMBER
XIDSQN NUMBER
...
74
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select XIDUSN, XIDSLOT, XIDSQN
2 from v$transaction
XIDUSN XIDSLOT XIDSQN
---------- ---------- ----------
1 31 674
SQL> select versions_xid from ...
VERSIONS_XID
-------------------
01 001F 00A202 0000
75
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> desc FLASHBACK_TRANSACTION_QUERY
Name Null? Type
----------------------- -------- --------------
XID RAW(8)
START_SCN NUMBER
START_TIMESTAMP DATE
COMMIT_SCN NUMBER
COMMIT_TIMESTAMP DATE
LOGON_USER VARCHAR2(30)
UNDO_CHANGE# NUMBER
OPERATION VARCHAR2(32)
TABLE_NAME VARCHAR2(256)
TABLE_OWNER VARCHAR2(32)
ROW_ID VARCHAR2(19)
UNDO_SQL VARCHAR2(4000)
76
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select DNAME from dept
2 where deptno = 10;
DNAME
-------
FINANCE
SQL> select xid, undo_sql
2 from flashback_transaction_query
3 where xid = hextoraw('09000d001d050000');
XID UNDO_SQL
---------------- ------------------------------------
09000D001D050000 update "SCOTT"."DEPT"
set "DNAME" = 'BEAN COUNTERS'
where ROWID = 'AAAQ+hAAEAAAAAOAAA';
77
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
be careful
78
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select text from dba_views
2 where view_name
3 = 'FLASHBACK_TRANSACTION_QUERY';
TEXT
------------------------------------------------
select
xid, start_scn, start_timestamp,
decode(commit_scn,
0, commit_scn,
281474976710655, NULL, commit_scn)
commit_scn, commit_timestamp,
logon_user, undo_change#, operation,
table_name, table_owner,
row_id, undo_sql
from SYS.X$KTUQQRY
79
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
do not query without predicates ...
80
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
do not forget hextoraw
81
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select xid, undo_sql
2 from flashback_transaction_query
3 where xid = hextoraw('09000d001d050000');
-----------------------------------------------------
| Id | Operation | Name |
-----------------------------------------------------
| 0 | SELECT STATEMENT | |
|* 1 | FIXED TABLE FIXED INDEX| X$KTUQQRY (ind:1) |
-----------------------------------------------------
83
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select xid, undo_sql
2 from flashback_transaction_query
3 where xid = '09000d001d050000';
--------------------------------------
| Id | Operation | Name |
--------------------------------------
| 0 | SELECT STATEMENT | |
| 1 | FIXED TABLE FULL| X$KTUQQRY |
--------------------------------------
84
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
UNDO_SQL
85
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
rollback committed transaction
86
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
"What's in it for me?"
87
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
three words
88
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
delete
uh-oh...
commit
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
90
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
undo a committed transaction
91
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback transaction
92
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> BEGIN
2 DBMS_FLASHBACK.TRANSACTION_BACKOUT(
3 numtxns=>1,
4 xids=>sys.xid_array('09000D001D050000')
5 );
6 END;
7 /
BEGIN
*
ERROR at line 1:
ORA-55510: Mining could not start
ORA-06512: at "SYS.DBMS_FLASHBACK", line 37
ORA-06512: at "SYS.DBMS_FLASHBACK", line 70
ORA-06512: at line 2
'09000D001D050000'
93
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
94
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> ALTER DATABASE ADD
2 SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
Database altered.
95
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> delete from DEPT
2 where DEPTNO = 10;
1 row deleted.
SQL> commit;
Commit complete.
SQL> SELECT VERSIONS_XID
2 FROM dept
3 VERSIONS BETWEEN SCN MINVALUE AND MAXVALUE;
VERSIONS_XID
----------------
080017006C040000
96
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> BEGIN
2 DBMS_FLASHBACK.TRANSACTION_BACKOUT(
3 numtxns=>1,
4 xids=>sys.xid_array('080017006C040000')
5 );
6 END;
7 /
SQL> select * from DEPT;
DEPTNO DNAME LOC
---------- -------------- ----------
20 RESEARCH DALLAS
30 SALES CHICAGO
50 MARKETING PERTH
40 HR US
97
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
KEEP CALM
AND
DON'T PANIC
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> SELECT COMPENSATING_XID
2 FROM DBA_FLASHBACK_TXN_STATE
3 WHERE xid = '080017006C040000';
COMPENSATING_XID
----------------
03001C0072040000
99
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> SELECT xid_report
2 FROM DBA_FLASHBACK_TXN_REPORT
3 WHERE compensating_xid = '03001C0072040000';
XID_REPORT
--------------------------------------------------------
<COMP_XID_REPORT XID="03001C0072040000">
<TRANSACTION XID="080017006C040000">
<UNDO_SQL>
<USQL exec="yes">
insert into "SCOTT"."DEPT"("DEPTNO","DNAME","LOC")
values ('10','ACCOUNTING','NEW YORK')
</USQL>
</UNDO_SQL>
</TRANSACTION>
<EXECUTED_UNDO_SQL>
<EXEC_USQL>
insert into "SCOTT"."DEPT"("DEPTNO","DNAME","LOC")
values ('10','ACCOUNTING','NEW YORK')
</EXEC_USQL>
</EXECUTED_UNDO_SQL>
</COMP_XID_REPORT> 100
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> commit;
Commit complete.
SQL> select * from dept;
DEPTNO DNAME LOC
---------- -------------- ----------
20 RESEARCH DALLAS
30 SALES CHICAGO
50 MARKETING PERTH
40 HR US
10 ACCOUNTING NEW YORK
101
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
some typical restrictions
102
ddl, old lobs, xml
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback
drop
103
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
delete
uh-oh...
commit
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback transaction
105
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
three words
two
106
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
drop
uh-oh...
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
108
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> desc EMP
ERROR:
ORA-04043: object EMP does not exist
109
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
hard
place
You are here
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
"undrop"
111
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
not cool enough
112
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback table to before drop
113
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> desc USER_RECYCLEBIN
Name Null? Type
----------------------------- -------- --------------------
OBJECT_NAME NOT NULL VARCHAR2(30)
ORIGINAL_NAME VARCHAR2(32)
OPERATION VARCHAR2(9)
TYPE VARCHAR2(25)
TS_NAME VARCHAR2(30)
CREATETIME VARCHAR2(19)
DROPTIME VARCHAR2(19)
DROPSCN NUMBER
PARTITION_NAME VARCHAR2(32)
CAN_UNDROP VARCHAR2(3)
CAN_PURGE VARCHAR2(3)
RELATED NOT NULL NUMBER
BASE_OBJECT NOT NULL NUMBER
PURGE_OBJECT NOT NULL NUMBER
SPACE NUMBER
115
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select OBJECT_NAME, ORIGINAL_NAME,
2 CAN_UNDROP, CAN_PURGE
3 from USER_RECYCLEBIN;
OBJECT_NAME ORIGINAL_NAME CAN CAN
-------------------------------- ------------------- --- ---
BIN$CmYCdNcITL6hp9l266nskA==$0 PK_EMP NO YES
BIN$b/W75+c/Q/CeFMBIK7cXfw==$0 EMP YES YES
116
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> show RECYCLEBIN
117
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
indexes / constraints / triggers
... all renamed
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> flashback table EMP to before drop;
Flashback complete.
119
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> flashback table EMP to before drop
2 rename to OLD_EMP;
Flashback complete.
120
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
indexes / constraints / triggers
... not renamed back
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
how long ?
122
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
1 second...
...10 years
123
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> PURGE RECYCLEBIN;
SQL> PURGE TABLE emp;
SQL> PURGE TABLE "BIN$xyWe0+q+SniItJ0pn/u54A==$0";
SQL> PURGE TABLESPACE user1;
SQL> PURGE INDEX "BIN$FTX34MN88J7==$0";
SQL> PURGE TABLESPACE user1 USER fred;
124
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
no untruncate
125
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback
table
126
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback table
128
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> FLASHBACK TABLE DEPT
2 TO TIMESTAMP TO_TIMESTAMP('2019-06-03 12:05:00')
129
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
"undrop"
130
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
"What's in it for me?"
131
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
repeatable tests without cleanup scripts
132
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
deletes modified rows since SCN
inserts fresh rows as of SCN
... busy
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> FLASHBACK TABLE DEPT
2 TO TIMESTAMP TO_TIMESTAMP('2019-06-03 12:05:00')
3 ENABLE TRIGGERS;
134
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
rowid's change
... enable row movement
135
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
indexes existence unaffected
136
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
single transaction
137
... multiple tables allowed
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
tables locked
138
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
R.I must still be valid
139
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
statistics unchanged
140
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
most DDL is a flashback boundary
141
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> flashback table DEPT to scn ...;
ORA-01466: unable to read data - table definition has changed
142
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
each release gets better
143
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> alter table DEPT add column XXX date;
SQL> flashback table DEPT to scn ...;
SQL> desc DEPT
Name Null? Type
-------------------------- -------- --------------
DEPTNO NUMBER(2)
DNAME VARCHAR2(14)
LOC VARCHAR2(13)
XXX DATE
144
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> flashback table DEPT to scn ...;
ORA-08183: Flashback cannot be enabled in the middle
of a transaction
145
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback
database
146
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback database
149
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
AUTHORISED
DATABASE
ADMINSTRATORS
ONLY !
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> alter database flashback on;
Database altered.
151
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
152
data
changes
"new" blocks
to disk
changes
to disk
"old" blocks
to disk
redo fbdadbwr
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> FLASHBACK DATABASE TO '2:05PM'
153
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> create restore point OK_SO_FAR;
...
SQL> flashback database to restore point OK_SO_FAR;
154
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
what does it cost ?
155
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> desc V$FLASHBACK_DATABASE_STAT
Name Null? Type
----------------------------- -------- ---------
BEGIN_TIME DATE
END_TIME DATE
FLASHBACK_DATA NUMBER
DB_DATA NUMBER
REDO_DATA NUMBER
ESTIMATED_FLASHBACK_SIZE NUMBER
156
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
a good compromise
157
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
guaranteed restore points
158
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback logging "optional"
159
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
less aggressive
160
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
"What's in it for me?"
161
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
1) safer deployment
162
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
scenario: "My New Application"
163
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
9:00
9:40
9:45 SQL> FLASHBACK DATABASE...
164
SQL> alter table ACCOUNTS ...
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
2) repeatable end to end testing
165
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
166
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
12.2+
167
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback pluggable database
168
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
3) production data for developers
169
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
"hidden" example
170
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
Data Guard
171
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
172
5:00am
11:30pm
standby recovery
convert to snapshot
revert to physical
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback
data archive
173
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
less flashback, more archive
174
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> CREATE FLASHBACK ARCHIVE longterm
2 TABLESPACE space_for_archive
3 RETENTION 1 YEAR;
Flashback archive created.
175
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> ALTER TABLE EMP FLASHBACK ARCHIVE LONGTERM;
Table altered.
[lots of DML on EMP]
176
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select * from EMP;
--------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
--------------------------------------------------
| 0 | SELECT STATEMENT | | 14 | 518 |
| 1 | TABLE ACCESS FULL| EMP | 14 | 518 |
--------------------------------------------------
177
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select * from EMP
2 AS OF TIMESTAMP SYSDATE-1/24;
--------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
--------------------------------------------------
| 0 | SELECT STATEMENT | | 14 | 518 |
| 1 | TABLE ACCESS FULL| EMP | 14 | 518 |
--------------------------------------------------
178
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
3 days later...
179
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select * from EMP
2 AS OF TIMESTAMP SYSDATE-3;
-----------------------------------------------------------------
| Id | Operation | Name | Rows |
-----------------------------------------------------------------
| 0 | SELECT STATEMENT | | 446 |
| 1 | VIEW | | 446 |
| 2 | UNION-ALL | | |
|* 3 | FILTER | | |
| 4 | PARTITION RANGE ITERATOR| | 445 |
|* 5 | TABLE ACCESS FULL | SYS_FBA_HIST_69539 | 445 |
|* 6 | FILTER | | |
|* 7 | HASH JOIN OUTER | | 1 |
|* 8 | TABLE ACCESS FULL | EMP | 1 |
|* 9 | TABLE ACCESS FULL | SYS_FBA_TCRV_69539 | 14 |
------------------------------------------------------------------180
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select table_name
2 from user_tables
3 /
TABLE_NAME
---------------------------
SYS_FBA_HIST_71036
SYS_FBA_TCRV_71036
SYS_FBA_DDL_COLMAP_71036
EMP
181
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
182
note
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
183
"The table does not use any of these
Flashback Data Archive reserved words
as column names:
• STARTSCN
• ENDSCN
• RID
• XID
• OP
• OPERATION"
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
"What's in it for me?"
184
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
"I don't care what EMP looked
like last March..."
185
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
186
why talk about it ?
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
187
SQL> select * from EMP AS OF "JUNE";
SQL> select * from EMP AS OF "MARCH";
SQL> select * from EMP AS OF "2pm Wednesday";
SQL> select * from EMP AS OF etc etc etc
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
188
every historical version...
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
189
... of every row
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
190
sound familiar ?
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
191
audit history
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
192
we've all done it
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
193
SQL> desc T
Name Null? Type
------------------------ -------- -------------
OWNER NOT NULL VARCHAR2(30)
OBJECT_NAME NOT NULL VARCHAR2(30)
SQL> desc T_AUDIT
Name Null? Type
------------------------ -------- --------------
AUDIT_DATE DATE
AUDIT_ACTION CHAR(1)
OWNER NOT NULL VARCHAR2(30)
OBJECT_NAME NOT NULL VARCHAR2(30)
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
194
SQL> create or replace
2 trigger AUDIT_TRG
3 after insert or update or delete on T
4 for each row
5 declare
6 v_action varchar2(1) := case when updating
7 then 'U' when deleting then 'D' else 'I' end;
8 begin
9 if updating or inserting then
10 insert into T_AUDIT
11 values (sysdate
12 ,v_action
13 ,:new.owner
14 ,:new.object_name);
15 else
16 insert into T_AUDIT
17 values (sysdate
18 ,v_action
19 ,:old.owner
20 ,:old.object_name);
21 end if;
22 end;
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
195
works but slow...
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
196
SQL> insert into T
2 select owner, object_name
3 from all_objects
4 where rownum <= 10000;
10000 rows created.
insert into T select owner, object_name
from all_objects where rownum <= 10000
call count cpu elapsed disk query current rows
------- ------ ------- ---------- -------- --------- ---------- ----------
Parse 1 0.01 0.00 0 0 0 0
Execute 1 3.10 3.05 88 123 10642 10000
Fetch 0 0.00 0.00 0 0 0 0
------- ------ ------- ---------- -------- --------- ---------- ----------
total 2 3.12 3.06 88 123 10642 10000
INSERT INTO T_AUDIT
VALUES (SYSDATE ,:B3 ,:B1 ,:B2 )
call count cpu elapsed disk query current rows
------- ------ ------- ---------- -------- --------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 10000 0.79 0.97 2 109 10845 10000
Fetch 0 0.00 0.00 0 0 0 0
------- ------ ------- ---------- -------- --------- ---------- ----------
total 10001 0.79 0.97 2 109 10845 10000
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
a better, faster, robust version ...
197
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback data archive
198
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select empno, ename, job, sal, comm,
2 nvl(VERSIONS_STARTTIME,LAST_MOD) TS
3 ,nvl(VERSIONS_OPERATION,'I') op
4 from EMP
5 versions between timestamp
6 timestamp '2019-02-11 20:12:00' and systimestamp
7 order by empno, ts;
EMPNO ENAME JOB SAL COMM TS O
---------- ---------- --------- ---------- ---------- ------------ -
7369 SMITH CLERK 806 08.10.51 PM I
7369 SMITH SALES 8060 1000 08.12.10 PM U
7499 ALLEN SALESMAN 1606 300000000 08.10.51 PM I
7521 WARD SALESMAN 1256 500000000 08.10.51 PM I
7566 JONES MANAGER 2981 08.10.51 PM I
...
7900 JAMES CLERK 956 08.10.51 PM I
7902 FORD ANALYST 3006 08.10.51 PM I
7934 MILLER CLERK 1306 08.10.51 PM I
7934 MILLER CLERK 1306 08.12.10 PM D
199
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
so why didn't we ?
200
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
reason 1
201
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
"yeah...but who ? where ? how ?"
202
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> alter table EMP add UPDATED_BY varchar2(10);
Table altered.
SQL> alter table EMP add UPDATED_PGM varchar2(10);
Table altered.
[etc]
203
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
reason 2
204
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
separately licensed
206
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
12c+ ... more options
207
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
1) context extension
208
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> begin
2 dbms_flashback_archive.set_context_level(
3 level=> 'ALL');
4 end;
PL/SQL procedure successfully completed.
209
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> update EMP
2 set sal = sal*10
3 where empno = 7499;
1 row updated.
SQL> commit;
210
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select XID from SYS_FBA_HIST_510592;
XID
----------------
09000B00C7080000
211
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> set serverout on
SQL> begin
2 dbms_output.put_line(
3 dbms_flashback_archive.get_sys_context (
4 '09000B00C7080000', 'USERENV', 'SESSION_USER'));
5
6 dbms_output.put_line(
7 dbms_flashback_archive.get_sys_context (
8 '09000B00C7080000', 'USERENV', 'HOST'));
9
10 dbms_output.put_line(
11 dbms_flashback_archive.get_sys_context (
12 '09000B00C7080000', 'USERENV', 'MODULE'));
13 end;
14 /
SCOTT
WORKGROUPXPS
SQL*Plus
212
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
...and a few other things :-)
213
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> desc SYS.SYS_FBA_CONTEXT_AUD
Name Null? Type
------------------------- -------- ------------------
XID RAW(8)
ACTION VARCHAR2(256)
AUTHENTICATED_IDENTITY VARCHAR2(256)
CLIENT_IDENTIFIER VARCHAR2(256)
CLIENT_INFO VARCHAR2(256)
CURRENT_EDITION_NAME VARCHAR2(256)
CURRENT_SCHEMA VARCHAR2(256)
CURRENT_USER VARCHAR2(256)
DATABASE_ROLE VARCHAR2(256)
DB_NAME VARCHAR2(256)
GLOBAL_UID VARCHAR2(256)
HOST VARCHAR2(256)
IDENTIFICATION_TYPE VARCHAR2(256)
INSTANCE_NAME VARCHAR2(256)
IP_ADDRESS VARCHAR2(256)
MODULE VARCHAR2(256) 214
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> @pt "select * from SYS.SYS_FBA_CONTEXT_AUD
where xid = '09000B00C7080000'"
XID : 09000B00C7080000
AUTHENTICATED_IDENTITY : scott
CLIENT_IDENTIFIER :
CLIENT_INFO :
CURRENT_EDITION_NAME : ORA$BASE
CURRENT_SCHEMA : SYS
CURRENT_USER : SYS
DATABASE_ROLE : PRIMARY
DB_NAME : np12
HOST : WORKGROUPXPS
IDENTIFICATION_TYPE : LOCAL
INSTANCE_NAME : np12
MODULE : SQL*Plus
OS_USER : xpshamcdc
SERVER_HOST : xps
...
215
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select empno, ename, job, sal, comm,
2 VERSIONS_XID
3 from EMP
4 versions between timestamp
5 timestamp '2019-02-11 20:12:00' and systimestamp
6 order by empno;
EMPNO ENAME JOB SAL COMM VERSIONS_XID
---------- ---------- --------- ---------- ---------- ----------------
7369 SMITH CLERK 806
7369 SMITH SALES 8060 1000 09001C00E04A0000
7499 ALLEN CLERK 16060 300000000 0A000A0024080000
7499 ALLEN SALESMAN 16060 300000000 09000B00C7080000
7499 ALLEN SALESMAN 1606 300000000
7521 WARD SALESMAN 1256 500000000
216
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select ...
2 from
3 ( select
4 empno, ename, job,
5 sal, comm, VERSIONS_XID
6 from EMP
7 versions between timestamp
8 timestamp '2019-02-11 20:12:00' and
9 systimestamp
10 ) e, SYS.SYS_FBA_CONTEXT_AUD a
11 where e.VERSIONS_XID = a.XID;
217
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
2) price...
218
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback data archive is now …
219
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
220
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
not a typo
221
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
basic versus advanced
222
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
choose your cost
compression
223
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
so think about FDA
224
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
secure
read only
225
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
efficient
fdba
226
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
all of your history...
227
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
... all of your audit
228
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
"Where were you in 2004 ?!?!?"
229
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
dbms_flashback_archive.import_history
230
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
be careful ... silent errors
231
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> ALTER TABLE EMP FLASHBACK ARCHIVE LONGTERM;
Table altered.
Flashback Archive:
Error ORA-1950 in SQL create table "SCOTT".SYS_FBA_DDL_COLMAP_91938
(STARTSCN NUMBER, ENDSCN NUMBER...
Flashback Archive:
Error ORA-942 in SQL insert into "SCOTT".SYS_FBA_DDL_COLMAP_91938
(ENDSCN, COLUMN_NAME, TYPE, ...
232
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
back to smon_scn_time
233
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
CREATE TABLE "SYS"."SMON_SCN_TIME"
( "THREAD" NUMBER,
"TIME_MP" NUMBER,
"TIME_DP" DATE,
"SCN_WRP" NUMBER,
"SCN_BAS" NUMBER,
"NUM_MAPPINGS" NUMBER,
"TIM_SCN_MAP" RAW(1200),
"SCN" NUMBER DEFAULT 0,
"ORIG_THREAD" NUMBER DEFAULT 0
) CLUSTER "SYS"."SMON_SCN_TO_TIME_AUX" ("THREAD")
234
2^16 = ~3.5 years
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
"Recreate SMON_SCN_TIME as non-clustered table"
Doc ID 2389804.1
235
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
other stuff
236
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
Session 1
Request
Block 3217,
SCN 4567192
Block 3217,
SCN 4567234
"ABC" Block 3217,
SCN 4567003,
change ABC => XYZ
undo segment block(s)
No good..too new
take a copy of the block
Locate
apply undo
Block 3217,
SCN 4567234
"ABC"
Block 3217,
SCN 4567234
"ABC"
Block 3217,
SCN 4567003
"XYZ"
Block 3217,
SCN 4567003
"XYZ"
Session 2
update emp
set ename = "ABC"
where empno = 1234;
commit;
Done !
237
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
ORA_ROWSCN
238
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> SELECT ORA_ROWSCN,empno,ename,sal
2 FROM emp;
ORA_ROWSCN EMPNO ENAME SAL
---------- ---------- ---------- ----------
1357038 7369 SMITH 800
1357038 7499 ALLEN 1600
1357038 7521 WARD 1250
1357038 7566 JONES 2975
1357038 7654 MARTIN 1250
1357038 7698 BLAKE 2850
1357038 7782 CLARK 2450
1357038 7788 SCOTT 3000
1357038 7839 KING 5000
1357038 7844 TURNER 1500
1357038 7876 ADAMS 1100
1357038 7900 JAMES 950
1357038 7902 FORD 3000
1357038 7934 MILLER 1300
239
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
block level SCN
240
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> UPDATE emp SET sal = 9999
2 WHERE empno = 7369;
SQL> SELECT ORA_ROWSCN,empno,ename,sal
2 FROM emp;
ORA_ROWSCN EMPNO ENAME SAL
---------- ---------- ---------- ----------
1357484 7369 SMITH 9999
1357484 7499 ALLEN 1600
1357484 7521 WARD 1250
1357484 7566 JONES 2975
1357484 7654 MARTIN 1250
1357484 7698 BLAKE 2850
1357484 7782 CLARK 2450
1357484 7788 SCOTT 3000
1357484 7839 KING 5000
1357484 7844 TURNER 1500
1357484 7876 ADAMS 1100
1357484 7900 JAMES 950
1357484 7902 FORD 3000
1357484 7934 MILLER 1300 241
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> CREATE TABLE newemp ROWDEPENDENCIES
2 AS SELECT * FROM emp;
242
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> UPDATE newemp SET sal = 9999
2 WHERE empno = 7369
SQL> SELECT ORA_ROWSCN,empno,ename,sal
2 FROM newemp;
ORA_ROWSCN EMPNO ENAME SAL
---------- ---------- ---------- ----------
1357558 7369 SMITH 9999
1357545 7499 ALLEN 1600
1357545 7521 WARD 1250
1357545 7566 JONES 2975
1357545 7654 MARTIN 1250
1357545 7698 BLAKE 2850
1357545 7782 CLARK 2450
1357545 7788 SCOTT 3000
1357545 7839 KING 5000
1357545 7844 TURNER 1500
1357545 7876 ADAMS 1100
1357545 7900 JAMES 950
1357545 7902 FORD 3000
1357545 7934 MILLER 1300
243
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
SQL> select ORA_ROWSCN,
SCN_TO_TIMESTAMP(ORA_ROWSCN)
2 FROM emp
3 WHERE ...
244
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
wrap up
245
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
flashback query
flashback table
flashback drop
flashback database
flashback transaction
flashback data archive
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
all included in EE
247
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
all cool for modern development
248
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
That's a wrap!
youtube bit.ly/youtube-connor
blog bit.ly/blog-connor
twitter bit.ly/twitter-connor

Contenu connexe

Tendances

Pattern Matching with SQL - APEX World Rotterdam 2019
Pattern Matching with SQL - APEX World Rotterdam 2019Pattern Matching with SQL - APEX World Rotterdam 2019
Pattern Matching with SQL - APEX World Rotterdam 2019Connor McDonald
 
Hyderabad Mar 2019 - Autonomous Database
Hyderabad Mar 2019 - Autonomous DatabaseHyderabad Mar 2019 - Autonomous Database
Hyderabad Mar 2019 - Autonomous DatabaseConnor McDonald
 
Latin America tour 2019 - Flashback
Latin America tour 2019 -  FlashbackLatin America tour 2019 -  Flashback
Latin America tour 2019 - FlashbackConnor McDonald
 
OpenWorld 2018 - Common Application Developer Disasters
OpenWorld 2018 - Common Application Developer DisastersOpenWorld 2018 - Common Application Developer Disasters
OpenWorld 2018 - Common Application Developer DisastersConnor McDonald
 
Sangam 18 - Database Development: Return of the SQL Jedi
Sangam 18 - Database Development: Return of the SQL JediSangam 18 - Database Development: Return of the SQL Jedi
Sangam 18 - Database Development: Return of the SQL JediConnor McDonald
 
Latin America Tour 2019 - 18c and 19c featues
Latin America Tour 2019   - 18c and 19c featuesLatin America Tour 2019   - 18c and 19c featues
Latin America Tour 2019 - 18c and 19c featuesConnor McDonald
 
Perth APAC Groundbreakers tour - SQL Techniques
Perth APAC Groundbreakers tour - SQL TechniquesPerth APAC Groundbreakers tour - SQL Techniques
Perth APAC Groundbreakers tour - SQL TechniquesConnor McDonald
 
APEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQLAPEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQLConnor McDonald
 
Sangam 18 - Great Applications with Great SQL
Sangam 18 - Great Applications with Great SQLSangam 18 - Great Applications with Great SQL
Sangam 18 - Great Applications with Great SQLConnor McDonald
 
Latin America Tour 2019 - 10 great sql features
Latin America Tour 2019  - 10 great sql featuresLatin America Tour 2019  - 10 great sql features
Latin America Tour 2019 - 10 great sql featuresConnor McDonald
 
Sangam 2019 - The Latest Features
Sangam 2019 - The Latest FeaturesSangam 2019 - The Latest Features
Sangam 2019 - The Latest FeaturesConnor McDonald
 
Sangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on AutonomousSangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on AutonomousConnor McDonald
 
Sangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolestSangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolestConnor McDonald
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQLConnor McDonald
 
12 Things About 12c Release 2 for Developers
12 Things About 12c Release 2 for Developers12 Things About 12c Release 2 for Developers
12 Things About 12c Release 2 for DevelopersConnor McDonald
 
UKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsUKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsConnor McDonald
 
Troubleshooting Tips and Tricks for Database 19c ILOUG Feb 2020
Troubleshooting Tips and Tricks for Database 19c   ILOUG Feb 2020Troubleshooting Tips and Tricks for Database 19c   ILOUG Feb 2020
Troubleshooting Tips and Tricks for Database 19c ILOUG Feb 2020Sandesh Rao
 

Tendances (20)

Pattern Matching with SQL - APEX World Rotterdam 2019
Pattern Matching with SQL - APEX World Rotterdam 2019Pattern Matching with SQL - APEX World Rotterdam 2019
Pattern Matching with SQL - APEX World Rotterdam 2019
 
Hyderabad Mar 2019 - Autonomous Database
Hyderabad Mar 2019 - Autonomous DatabaseHyderabad Mar 2019 - Autonomous Database
Hyderabad Mar 2019 - Autonomous Database
 
Latin America tour 2019 - Flashback
Latin America tour 2019 -  FlashbackLatin America tour 2019 -  Flashback
Latin America tour 2019 - Flashback
 
OpenWorld 2018 - Common Application Developer Disasters
OpenWorld 2018 - Common Application Developer DisastersOpenWorld 2018 - Common Application Developer Disasters
OpenWorld 2018 - Common Application Developer Disasters
 
Sangam 18 - Database Development: Return of the SQL Jedi
Sangam 18 - Database Development: Return of the SQL JediSangam 18 - Database Development: Return of the SQL Jedi
Sangam 18 - Database Development: Return of the SQL Jedi
 
Latin America Tour 2019 - 18c and 19c featues
Latin America Tour 2019   - 18c and 19c featuesLatin America Tour 2019   - 18c and 19c featues
Latin America Tour 2019 - 18c and 19c featues
 
Perth APAC Groundbreakers tour - SQL Techniques
Perth APAC Groundbreakers tour - SQL TechniquesPerth APAC Groundbreakers tour - SQL Techniques
Perth APAC Groundbreakers tour - SQL Techniques
 
APEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQLAPEX Connect 2019 - array/bulk processing in PLSQL
APEX Connect 2019 - array/bulk processing in PLSQL
 
Sangam 18 - Great Applications with Great SQL
Sangam 18 - Great Applications with Great SQLSangam 18 - Great Applications with Great SQL
Sangam 18 - Great Applications with Great SQL
 
Latin America Tour 2019 - 10 great sql features
Latin America Tour 2019  - 10 great sql featuresLatin America Tour 2019  - 10 great sql features
Latin America Tour 2019 - 10 great sql features
 
Sangam 2019 - The Latest Features
Sangam 2019 - The Latest FeaturesSangam 2019 - The Latest Features
Sangam 2019 - The Latest Features
 
KScope19 - SQL Features
KScope19 - SQL FeaturesKScope19 - SQL Features
KScope19 - SQL Features
 
Sangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on AutonomousSangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on Autonomous
 
Sangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolestSangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolest
 
ANSI vs Oracle language
ANSI vs Oracle languageANSI vs Oracle language
ANSI vs Oracle language
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQL
 
12 Things About 12c Release 2 for Developers
12 Things About 12c Release 2 for Developers12 Things About 12c Release 2 for Developers
12 Things About 12c Release 2 for Developers
 
UKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsUKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tips
 
Flashback ITOUG
Flashback ITOUGFlashback ITOUG
Flashback ITOUG
 
Troubleshooting Tips and Tricks for Database 19c ILOUG Feb 2020
Troubleshooting Tips and Tricks for Database 19c   ILOUG Feb 2020Troubleshooting Tips and Tricks for Database 19c   ILOUG Feb 2020
Troubleshooting Tips and Tricks for Database 19c ILOUG Feb 2020
 

Similaire à Kscope19 - Flashback: Good for Developers as well as DBAs

ILOUG 2019 - Flashback, the forgotten feature
ILOUG 2019 - Flashback, the forgotten featureILOUG 2019 - Flashback, the forgotten feature
ILOUG 2019 - Flashback, the forgotten featureConnor McDonald
 
OG Yatra - Flashback, not just for developers
OG Yatra - Flashback, not just for developersOG Yatra - Flashback, not just for developers
OG Yatra - Flashback, not just for developersConnor McDonald
 
Melbourne Groundbreakers Tour - Hints and Tips
Melbourne Groundbreakers Tour - Hints and TipsMelbourne Groundbreakers Tour - Hints and Tips
Melbourne Groundbreakers Tour - Hints and TipsConnor McDonald
 
ITOUG 2019 - 18c, 19c features
ITOUG 2019 - 18c, 19c featuresITOUG 2019 - 18c, 19c features
ITOUG 2019 - 18c, 19c featuresConnor McDonald
 
18c and 19c features for DBAs
18c and 19c features for DBAs18c and 19c features for DBAs
18c and 19c features for DBAsConnor McDonald
 
ILOUG 2019 - 25 years of hints and tips
ILOUG 2019 - 25 years of hints and tipsILOUG 2019 - 25 years of hints and tips
ILOUG 2019 - 25 years of hints and tipsConnor McDonald
 
ILOUG 2019 - 18c/19c features
ILOUG 2019 - 18c/19c featuresILOUG 2019 - 18c/19c features
ILOUG 2019 - 18c/19c featuresConnor McDonald
 
OG Yatra - 25 years of hints and tips
OG Yatra - 25 years of hints and tipsOG Yatra - 25 years of hints and tips
OG Yatra - 25 years of hints and tipsConnor McDonald
 
Perth APAC Groundbreakers tour - 18c features
Perth APAC Groundbreakers tour - 18c featuresPerth APAC Groundbreakers tour - 18c features
Perth APAC Groundbreakers tour - 18c featuresConnor McDonald
 
Hyderabad Mar 2019 - Database 18c / 19c
Hyderabad Mar 2019 - Database 18c / 19cHyderabad Mar 2019 - Database 18c / 19c
Hyderabad Mar 2019 - Database 18c / 19cConnor McDonald
 
ITOUG 2019 - 25 years of hints and tips
ITOUG 2019 - 25 years of hints and tipsITOUG 2019 - 25 years of hints and tips
ITOUG 2019 - 25 years of hints and tipsConnor McDonald
 
Flashback features in Oracle - UKOUG 2017
Flashback features in Oracle - UKOUG 2017Flashback features in Oracle - UKOUG 2017
Flashback features in Oracle - UKOUG 2017Connor McDonald
 
Wellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
Wellington APAC Groundbreakers tour - Upgrading to the 12c OptimizerWellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
Wellington APAC Groundbreakers tour - Upgrading to the 12c OptimizerConnor McDonald
 
Troubleshooting Ecommerce Performance
 Troubleshooting Ecommerce Performance Troubleshooting Ecommerce Performance
Troubleshooting Ecommerce PerformanceDiego Cardozo
 
OG Yatra - upgrading to the new 12c+ optimizer
OG Yatra - upgrading to the new 12c+ optimizerOG Yatra - upgrading to the new 12c+ optimizer
OG Yatra - upgrading to the new 12c+ optimizerConnor McDonald
 
SQL and PLSQL features for APEX Developers
SQL and PLSQL features for APEX DevelopersSQL and PLSQL features for APEX Developers
SQL and PLSQL features for APEX DevelopersConnor McDonald
 
OOW19 - Killing database sessions
OOW19 - Killing database sessionsOOW19 - Killing database sessions
OOW19 - Killing database sessionsConnor McDonald
 
OpenWorld 2018 - SQL Tuning in 20 mins
OpenWorld 2018 - SQL Tuning in 20 minsOpenWorld 2018 - SQL Tuning in 20 mins
OpenWorld 2018 - SQL Tuning in 20 minsConnor McDonald
 
AskTOM Office Hours on Database Triggers
AskTOM Office Hours on Database TriggersAskTOM Office Hours on Database Triggers
AskTOM Office Hours on Database TriggersSteven Feuerstein
 
APAC Groundbreakers 2019 - Perth/Melbourne
APAC Groundbreakers 2019 - Perth/Melbourne APAC Groundbreakers 2019 - Perth/Melbourne
APAC Groundbreakers 2019 - Perth/Melbourne Connor McDonald
 

Similaire à Kscope19 - Flashback: Good for Developers as well as DBAs (20)

ILOUG 2019 - Flashback, the forgotten feature
ILOUG 2019 - Flashback, the forgotten featureILOUG 2019 - Flashback, the forgotten feature
ILOUG 2019 - Flashback, the forgotten feature
 
OG Yatra - Flashback, not just for developers
OG Yatra - Flashback, not just for developersOG Yatra - Flashback, not just for developers
OG Yatra - Flashback, not just for developers
 
Melbourne Groundbreakers Tour - Hints and Tips
Melbourne Groundbreakers Tour - Hints and TipsMelbourne Groundbreakers Tour - Hints and Tips
Melbourne Groundbreakers Tour - Hints and Tips
 
ITOUG 2019 - 18c, 19c features
ITOUG 2019 - 18c, 19c featuresITOUG 2019 - 18c, 19c features
ITOUG 2019 - 18c, 19c features
 
18c and 19c features for DBAs
18c and 19c features for DBAs18c and 19c features for DBAs
18c and 19c features for DBAs
 
ILOUG 2019 - 25 years of hints and tips
ILOUG 2019 - 25 years of hints and tipsILOUG 2019 - 25 years of hints and tips
ILOUG 2019 - 25 years of hints and tips
 
ILOUG 2019 - 18c/19c features
ILOUG 2019 - 18c/19c featuresILOUG 2019 - 18c/19c features
ILOUG 2019 - 18c/19c features
 
OG Yatra - 25 years of hints and tips
OG Yatra - 25 years of hints and tipsOG Yatra - 25 years of hints and tips
OG Yatra - 25 years of hints and tips
 
Perth APAC Groundbreakers tour - 18c features
Perth APAC Groundbreakers tour - 18c featuresPerth APAC Groundbreakers tour - 18c features
Perth APAC Groundbreakers tour - 18c features
 
Hyderabad Mar 2019 - Database 18c / 19c
Hyderabad Mar 2019 - Database 18c / 19cHyderabad Mar 2019 - Database 18c / 19c
Hyderabad Mar 2019 - Database 18c / 19c
 
ITOUG 2019 - 25 years of hints and tips
ITOUG 2019 - 25 years of hints and tipsITOUG 2019 - 25 years of hints and tips
ITOUG 2019 - 25 years of hints and tips
 
Flashback features in Oracle - UKOUG 2017
Flashback features in Oracle - UKOUG 2017Flashback features in Oracle - UKOUG 2017
Flashback features in Oracle - UKOUG 2017
 
Wellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
Wellington APAC Groundbreakers tour - Upgrading to the 12c OptimizerWellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
Wellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
 
Troubleshooting Ecommerce Performance
 Troubleshooting Ecommerce Performance Troubleshooting Ecommerce Performance
Troubleshooting Ecommerce Performance
 
OG Yatra - upgrading to the new 12c+ optimizer
OG Yatra - upgrading to the new 12c+ optimizerOG Yatra - upgrading to the new 12c+ optimizer
OG Yatra - upgrading to the new 12c+ optimizer
 
SQL and PLSQL features for APEX Developers
SQL and PLSQL features for APEX DevelopersSQL and PLSQL features for APEX Developers
SQL and PLSQL features for APEX Developers
 
OOW19 - Killing database sessions
OOW19 - Killing database sessionsOOW19 - Killing database sessions
OOW19 - Killing database sessions
 
OpenWorld 2018 - SQL Tuning in 20 mins
OpenWorld 2018 - SQL Tuning in 20 minsOpenWorld 2018 - SQL Tuning in 20 mins
OpenWorld 2018 - SQL Tuning in 20 mins
 
AskTOM Office Hours on Database Triggers
AskTOM Office Hours on Database TriggersAskTOM Office Hours on Database Triggers
AskTOM Office Hours on Database Triggers
 
APAC Groundbreakers 2019 - Perth/Melbourne
APAC Groundbreakers 2019 - Perth/Melbourne APAC Groundbreakers 2019 - Perth/Melbourne
APAC Groundbreakers 2019 - Perth/Melbourne
 

Plus de Connor McDonald

UKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresUKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresConnor McDonald
 
APEX tour 2019 - successful development with autonomous
APEX tour 2019 - successful development with autonomousAPEX tour 2019 - successful development with autonomous
APEX tour 2019 - successful development with autonomousConnor McDonald
 
OOW19 - Flashback, not just for DBAs
OOW19 - Flashback, not just for DBAsOOW19 - Flashback, not just for DBAs
OOW19 - Flashback, not just for DBAsConnor McDonald
 
OOW19 - Read consistency
OOW19 - Read consistencyOOW19 - Read consistency
OOW19 - Read consistencyConnor McDonald
 
OOW19 - Slower and less secure applications
OOW19 - Slower and less secure applicationsOOW19 - Slower and less secure applications
OOW19 - Slower and less secure applicationsConnor McDonald
 
OOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL featuresOOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL featuresConnor McDonald
 
Kscope19 - Understanding the basics of SQL processing
Kscope19 - Understanding the basics of SQL processingKscope19 - Understanding the basics of SQL processing
Kscope19 - Understanding the basics of SQL processingConnor McDonald
 

Plus de Connor McDonald (7)

UKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresUKOUG 2019 - SQL features
UKOUG 2019 - SQL features
 
APEX tour 2019 - successful development with autonomous
APEX tour 2019 - successful development with autonomousAPEX tour 2019 - successful development with autonomous
APEX tour 2019 - successful development with autonomous
 
OOW19 - Flashback, not just for DBAs
OOW19 - Flashback, not just for DBAsOOW19 - Flashback, not just for DBAs
OOW19 - Flashback, not just for DBAs
 
OOW19 - Read consistency
OOW19 - Read consistencyOOW19 - Read consistency
OOW19 - Read consistency
 
OOW19 - Slower and less secure applications
OOW19 - Slower and less secure applicationsOOW19 - Slower and less secure applications
OOW19 - Slower and less secure applications
 
OOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL featuresOOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL features
 
Kscope19 - Understanding the basics of SQL processing
Kscope19 - Understanding the basics of SQL processingKscope19 - Understanding the basics of SQL processing
Kscope19 - Understanding the basics of SQL processing
 

Dernier

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Dernier (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Kscope19 - Flashback: Good for Developers as well as DBAs

  • 1.
  • 2. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 2
  • 3. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 3
  • 4. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Stuff youtube bit.ly/youtube-connor blog bit.ly/blog-connor twitter bit.ly/twitter-connor 400+ posts mainly on database & development 250 technical videos, new uploads every week rants and raves on tech and the world :-)
  • 5. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. etc... facebook bit.ly/facebook-connor linkedin bit.ly/linkedin-connor instagram bit.ly/instagram-connor slideshare bit.ly/slideshare-connor
  • 6. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | https://asktom.oracle.com
  • 7. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 7https://asktom.oracle.com/officehours
  • 8. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
  • 9. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
  • 10. Flashback - the forgotten feature Connor McDonald Database Advocate
  • 11. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback 11
  • 12. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com several technologies 12
  • 13. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback query flashback table flashback drop flashback database flashback transaction flashback data archive
  • 14. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback query 14
  • 15. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com controversy 15
  • 16. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com you have always... 16
  • 17. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com .. been using flashback query 17
  • 18. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com revision 18
  • 19. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> update EMP 2 set SAL = SAL * 1.10 3 / 14 rows updated. SQL> rollback; Rollback complete. how ? 19
  • 20. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com we remember stuff 20
  • 21. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> update EMP 2 set SAL = SAL * 1.10 3 / undo header smith $1,0001 block 2754 jones $9002 brown $1,5003 wells $2,0004 wilson $1,0005 block 2754, row 1, sal $1000 block 2754, row 2, sal $900 block 2754, row 3, sal $1500 block 2754, row 4, sal $2000 uba 5 5 $1,100 $990 $1,650 $2,200 uba 5.1uba 5.2
  • 22. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> rollback; 22
  • 23. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> rollback; undo header smith $1,0001 block 2754 jones $9002 brown $1,5003 wells $2,0004 wilson $1,0005 block 2754, row 1, sal $1000 block 2754, row 2, sal $900 block 2754, row 3, sal $1500 block 2754, row 4, sal $2000 uba 5 5 $1,100 $990 $1,650 $2,200 uba 5.1uba 5.2
  • 24. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com we can use this stuff for queries! (Oracle version 4) 24
  • 25. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com read consistency 25
  • 26. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com select * from emp where hiredate > '01/01/2004' update emp set … where empno = 1234; Block 3217 "I need block 3217… … as it was at 9:00" 9:00 9:03 9:05 session 1 session 2 ...and time = scn
  • 27. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com system change number 27
  • 28. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com Session 1 Request Block 3217, SCN 4567192 Block 3217, SCN 4567234 "ABC" Block 3217, SCN 4567003, change ABC => XYZ undo segment block(s) No good..too new take a copy of the block Locate apply undo Block 3217, SCN 4567234 "ABC" Block 3217, SCN 4567234 "ABC" Block 3217, SCN 4567003 "XYZ" Block 3217, SCN 4567003 "XYZ" Session 2 update emp set ename = "ABC" where empno = 1234; commit; Done ! 28
  • 29. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com every query = locked at a SCN 29
  • 30. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 30 go back even further....
  • 31. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback query = choose SCN 31
  • 32. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com v9 32
  • 33. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select * from DEPT; DEPTNO DNAME LOC ---------- -------------- ------------- 10 UNKNOWN NEW YORK 20 UNKNOWN DALLAS 30 UNKNOWN CHICAGO 40 UNKNOWN BOSTON 33
  • 34. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select * from DEPT AS OF SCN 995401; DEPTNO DNAME LOC ---------- -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON 34
  • 35. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com a little less geeky 35
  • 36. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select * from DEPT 2 AS OF TIMESTAMP systimestamp - 3 interval '20:00' minute to second; DEPTNO DNAME LOC ---------- -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON 36
  • 37. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com smon_scn_time 37
  • 38. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com smon_scn_time ??? 38
  • 39. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com obsolete* 39 more later on this
  • 40. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select TIMESTAMP_TO_SCN(systimestamp) from DUAL; TIMESTAMP_TO_SCN(SYSTIMESTAMP) ------------------------------ 998332 40
  • 41. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select SCN_TO_TIMESTAMP(998314) from DUAL; SCN_TO_TIMESTAMP(998314) ----------------------------------------------- 25-FEB-19 09.12.48.000000000 PM 41
  • 42. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 3 seconds 42
  • 43. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select scn_to_timestamp(2409511-rownum) 2 from dual 3 connect by level <= 50; SCN_TO_TIMESTAMP(2409511-ROWNUM) --------------------------------------------- 28-FEB-19 05.47.47.000000000 PM 28-FEB-19 05.47.47.000000000 PM 28-FEB-19 05.47.44.000000000 PM 28-FEB-19 05.47.41.000000000 PM 28-FEB-19 05.47.37.000000000 PM 28-FEB-19 05.47.34.000000000 PM 28-FEB-19 05.47.31.000000000 PM 28-FEB-19 05.47.28.000000000 PM 28-FEB-19 05.47.25.000000000 PM 43
  • 44. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com use in "normal" queries 44
  • 45. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select e.empno, e.ename, d.dname 2 from emp e, 3 dept AS OF TIMESTAMP '23-FEB-19 11.51.02 PM' d 3 where d.deptno = e.deptno; EMPNO ENAME DNAME ---------- ---------- -------------- 7782 CLARK "PREVIOUS NAME" 7839 KING "PREVIOUS NAME" 7934 MILLER "PREVIOUS NAME" 7566 JONES RESEARCH 7902 FORD RESEARCH 7876 ADAMS RESEARCH 7369 SMITH RESEARCH 7788 SCOTT RESEARCH 45
  • 46. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com "What's in it for me?" 46
  • 47. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 1) unit testing 47
  • 48. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select case 2 when d1.deptno is null then 'DELETE' 3 when d2.deptno is null then 'INSERT' 4 end action, 5 d1.deptno, d2.deptno, d1.dname, d1.loc 6 from DEPT d1 full outer join 7 DEPT AS OF TIMESTAMP '23-FEB-19 11.51.02 PM' d2 8 on d1.deptno = d2.deptno; ACTION DEPTNO DEPTNO DNAME LOC ------ ---------- ---------- -------------- ---------- 10 10 ACCOUNTING NEW YORK 20 20 RESEARCH DALLAS 30 30 SALES CHICAGO DELETE 40 INSERT 50 MARKETING PERTH 48
  • 49. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 2) not just your data 49
  • 50. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> drop procedure debug_msg; Procedure dropped. SQL> connect / as sysdba Connected. SQL> select text 2 from dba_source 3 as of timestamp systimestamp - interval '5' minute 4 where name='DEBUG_MSG' order by line; TEXT --------------------------------------------------------------------- procedure debug_msg(m varchar2) is begin dbms_output.put_line(m); dbms_application_info.set_client_info(m); end; 5 rows selected. 50
  • 51. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 3) functional diagnosis 51
  • 52. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select * from DEPT; DEPTNO DNAME LOC ---------- -------------- ------------- 10 UNKNOWN NEW YORK SQL> select * from DEPT 2 as of TIMESTAMP SYSTIMESTAMP - 3 INTERVAL '20:00' MINUTE TO SECOND; DEPTNO DNAME LOC ---------- -------------- ------------- 10 ACCOUNTING NEW YORK 1 change ? 10 changes ?
  • 53. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback row versions 53
  • 54. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> SELECT deptno, dname 2 FROM dept 3 VERSIONS BETWEEN 4 TIMESTAMP SYSTIMESTAMP – 5 INTERVAL '20:00' MINUTE TO SECOND 6 AND SYSTIMESTAMP 7 WHERE deptno = 10; DEPTNO DNAME ---------- -------------- 10 ACCOUNTING 10 MONEY GRABBERS 10 FINANCE 10 BEAN COUNTERS 10 UNKNOWN 1 row 5 versions 54
  • 55. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com versions_starttime versions_startscn versions_endtime versions_endscn versions_xid versions_operation 55
  • 56. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> SELECT deptno, dname, 2 VERSIONS_STARTTIME 3 ,VERSIONS_XID 4 ,VERSIONS_OPERATION 5 FROM dept 6 VERSIONS BETWEEN 7 TIMESTAMP SYSTIMESTAMP - INTERVAL '20:00' MINUTE TO SECOND 8 AND SYSTIMESTAMP 9 WHERE deptno = 10; DEPTNO DNAME VERSIONS_STARTTIME VERSIONS_XID V ---------- -------------- ------------------------ ---------------- - 10 UNKNOWN 03-SEP-18 11.53.45 PM 0200100060040000 U 10 MONEY GRABBERS 03-SEP-18 11.53.36 PM 0600050065040000 U 10 FINANCE 03-SEP-18 11.53.24 PM 09000D001D050000 U 10 BEAN COUNTERS 03-SEP-18 11.53.12 PM 01001A00EA030000 U 10 ACCOUNTING 56
  • 57. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com get the lot ... 57
  • 58. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> SELECT deptno, dname, 2 VERSIONS_STARTTIME 3 ,VERSIONS_XID 4 ,VERSIONS_OPERATION 5 FROM dept VERSIONS BETWEEN SCN MINVALUE AND MAXVALUE; DEPTNO DNAME VERSIONS_STARTTIME VERSIONS_XID V ---------- -------------- ------------------------ ---------------- - 50 UNKNOWN 03-SEP-18 11.08.15 PM 04000700EA030000 U 30 UNKNOWN 03-SEP-18 11.08.15 PM 04000700EA030000 U 20 NERDS 03-SEP-18 11.07.57 PM 090016001D050000 U 20 R&D 03-SEP-18 11.07.48 PM 05000B0074040000 U ...
  • 59. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com grant flashback to ... 59
  • 60. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com session level 60
  • 61. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com dbms_flashback.enable_at_time(systimestamp-1); 61
  • 62. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> exec dbms_flashback.enable_at_time( systimestamp-5/86400) PL/SQL procedure successfully completed. SQL> insert into T values (1); ERROR at line 1: ORA-08182: operation not supported while in Flashback mode 62
  • 63. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> exec dbms_flashback.disable; PL/SQL procedure successfully completed. SQL> exec dbms_flashback.enable_at_time( systimestamp-30/86400) PL/SQL procedure successfully completed. SQL> exec dbms_flashback.enable_at_time( systimestamp-60/86400) ERROR at line 1: ORA-08184: attempting to re-enable Flashback while in Flashback 63
  • 64. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com just how far ? 64
  • 65. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com undo_retention 65
  • 66. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> show parameter undo_retention NAME TYPE VALUE ------------------------------ ----------- -------- undo_retention integer 900 66 ~
  • 67. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> desc v$undostat Name Null? Type ----------------------------- -------- ---------------- BEGIN_TIME DATE END_TIME DATE ... ... TUNED_UNDORETENTION NUMBER CON_ID NUMBER 67
  • 68. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com much much further flashback data archive
  • 69. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com "no" spanning DDL 69 better each version
  • 70. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com rewind the data, not time 70 charactersets, NLS etc
  • 71. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback transaction 71
  • 72. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> SELECT deptno, dname, 2 VERSIONS_STARTTIME 3 ,VERSIONS_XID 4 ,VERSIONS_OPERATION 5 FROM dept VERSIONS BETWEEN SCN MINVALUE AND MAXVALUE; DEPTNO DNAME VERSIONS_STARTTIME VERSIONS_XID V ---------- -------------- ------------------------ ---------------- - 50 UNKNOWN 03-SEP-18 11.08.15 PM 04000700EA030000 U 30 UNKNOWN 03-SEP-18 11.08.15 PM 04000700EA030000 U 20 NERDS 03-SEP-18 11.07.57 PM 090016001D050000 U 20 R&D 03-SEP-18 11.07.48 PM 05000B0074040000 U ...
  • 73. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com XID ? 73
  • 74. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> desc V$TRANSACTION Name Null? Type ----------------------------- -------- ------- XIDUSN NUMBER XIDSLOT NUMBER XIDSQN NUMBER ... 74
  • 75. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select XIDUSN, XIDSLOT, XIDSQN 2 from v$transaction XIDUSN XIDSLOT XIDSQN ---------- ---------- ---------- 1 31 674 SQL> select versions_xid from ... VERSIONS_XID ------------------- 01 001F 00A202 0000 75
  • 76. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> desc FLASHBACK_TRANSACTION_QUERY Name Null? Type ----------------------- -------- -------------- XID RAW(8) START_SCN NUMBER START_TIMESTAMP DATE COMMIT_SCN NUMBER COMMIT_TIMESTAMP DATE LOGON_USER VARCHAR2(30) UNDO_CHANGE# NUMBER OPERATION VARCHAR2(32) TABLE_NAME VARCHAR2(256) TABLE_OWNER VARCHAR2(32) ROW_ID VARCHAR2(19) UNDO_SQL VARCHAR2(4000) 76
  • 77. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select DNAME from dept 2 where deptno = 10; DNAME ------- FINANCE SQL> select xid, undo_sql 2 from flashback_transaction_query 3 where xid = hextoraw('09000d001d050000'); XID UNDO_SQL ---------------- ------------------------------------ 09000D001D050000 update "SCOTT"."DEPT" set "DNAME" = 'BEAN COUNTERS' where ROWID = 'AAAQ+hAAEAAAAAOAAA'; 77
  • 78. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com be careful 78
  • 79. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select text from dba_views 2 where view_name 3 = 'FLASHBACK_TRANSACTION_QUERY'; TEXT ------------------------------------------------ select xid, start_scn, start_timestamp, decode(commit_scn, 0, commit_scn, 281474976710655, NULL, commit_scn) commit_scn, commit_timestamp, logon_user, undo_change#, operation, table_name, table_owner, row_id, undo_sql from SYS.X$KTUQQRY 79
  • 80. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com do not query without predicates ... 80
  • 81. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com do not forget hextoraw 81
  • 82. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
  • 83. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select xid, undo_sql 2 from flashback_transaction_query 3 where xid = hextoraw('09000d001d050000'); ----------------------------------------------------- | Id | Operation | Name | ----------------------------------------------------- | 0 | SELECT STATEMENT | | |* 1 | FIXED TABLE FIXED INDEX| X$KTUQQRY (ind:1) | ----------------------------------------------------- 83
  • 84. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select xid, undo_sql 2 from flashback_transaction_query 3 where xid = '09000d001d050000'; -------------------------------------- | Id | Operation | Name | -------------------------------------- | 0 | SELECT STATEMENT | | | 1 | FIXED TABLE FULL| X$KTUQQRY | -------------------------------------- 84
  • 85. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com UNDO_SQL 85
  • 86. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com rollback committed transaction 86
  • 87. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com "What's in it for me?" 87
  • 88. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com three words 88
  • 89. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com delete uh-oh... commit
  • 90. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 90
  • 91. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com undo a committed transaction 91
  • 92. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback transaction 92
  • 93. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> BEGIN 2 DBMS_FLASHBACK.TRANSACTION_BACKOUT( 3 numtxns=>1, 4 xids=>sys.xid_array('09000D001D050000') 5 ); 6 END; 7 / BEGIN * ERROR at line 1: ORA-55510: Mining could not start ORA-06512: at "SYS.DBMS_FLASHBACK", line 37 ORA-06512: at "SYS.DBMS_FLASHBACK", line 70 ORA-06512: at line 2 '09000D001D050000' 93
  • 94. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 94
  • 95. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> ALTER DATABASE ADD 2 SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS; Database altered. 95
  • 96. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> delete from DEPT 2 where DEPTNO = 10; 1 row deleted. SQL> commit; Commit complete. SQL> SELECT VERSIONS_XID 2 FROM dept 3 VERSIONS BETWEEN SCN MINVALUE AND MAXVALUE; VERSIONS_XID ---------------- 080017006C040000 96
  • 97. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> BEGIN 2 DBMS_FLASHBACK.TRANSACTION_BACKOUT( 3 numtxns=>1, 4 xids=>sys.xid_array('080017006C040000') 5 ); 6 END; 7 / SQL> select * from DEPT; DEPTNO DNAME LOC ---------- -------------- ---------- 20 RESEARCH DALLAS 30 SALES CHICAGO 50 MARKETING PERTH 40 HR US 97
  • 98. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com KEEP CALM AND DON'T PANIC
  • 99. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> SELECT COMPENSATING_XID 2 FROM DBA_FLASHBACK_TXN_STATE 3 WHERE xid = '080017006C040000'; COMPENSATING_XID ---------------- 03001C0072040000 99
  • 100. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> SELECT xid_report 2 FROM DBA_FLASHBACK_TXN_REPORT 3 WHERE compensating_xid = '03001C0072040000'; XID_REPORT -------------------------------------------------------- <COMP_XID_REPORT XID="03001C0072040000"> <TRANSACTION XID="080017006C040000"> <UNDO_SQL> <USQL exec="yes"> insert into "SCOTT"."DEPT"("DEPTNO","DNAME","LOC") values ('10','ACCOUNTING','NEW YORK') </USQL> </UNDO_SQL> </TRANSACTION> <EXECUTED_UNDO_SQL> <EXEC_USQL> insert into "SCOTT"."DEPT"("DEPTNO","DNAME","LOC") values ('10','ACCOUNTING','NEW YORK') </EXEC_USQL> </EXECUTED_UNDO_SQL> </COMP_XID_REPORT> 100
  • 101. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> commit; Commit complete. SQL> select * from dept; DEPTNO DNAME LOC ---------- -------------- ---------- 20 RESEARCH DALLAS 30 SALES CHICAGO 50 MARKETING PERTH 40 HR US 10 ACCOUNTING NEW YORK 101
  • 102. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com some typical restrictions 102 ddl, old lobs, xml
  • 103. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback drop 103
  • 104. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com delete uh-oh... commit
  • 105. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback transaction 105
  • 106. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com three words two 106
  • 107. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com drop uh-oh...
  • 108. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 108
  • 109. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> desc EMP ERROR: ORA-04043: object EMP does not exist 109
  • 110. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com hard place You are here
  • 111. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com "undrop" 111
  • 112. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com not cool enough 112
  • 113. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback table to before drop 113
  • 114. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
  • 115. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> desc USER_RECYCLEBIN Name Null? Type ----------------------------- -------- -------------------- OBJECT_NAME NOT NULL VARCHAR2(30) ORIGINAL_NAME VARCHAR2(32) OPERATION VARCHAR2(9) TYPE VARCHAR2(25) TS_NAME VARCHAR2(30) CREATETIME VARCHAR2(19) DROPTIME VARCHAR2(19) DROPSCN NUMBER PARTITION_NAME VARCHAR2(32) CAN_UNDROP VARCHAR2(3) CAN_PURGE VARCHAR2(3) RELATED NOT NULL NUMBER BASE_OBJECT NOT NULL NUMBER PURGE_OBJECT NOT NULL NUMBER SPACE NUMBER 115
  • 116. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select OBJECT_NAME, ORIGINAL_NAME, 2 CAN_UNDROP, CAN_PURGE 3 from USER_RECYCLEBIN; OBJECT_NAME ORIGINAL_NAME CAN CAN -------------------------------- ------------------- --- --- BIN$CmYCdNcITL6hp9l266nskA==$0 PK_EMP NO YES BIN$b/W75+c/Q/CeFMBIK7cXfw==$0 EMP YES YES 116
  • 117. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> show RECYCLEBIN 117
  • 118. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com indexes / constraints / triggers ... all renamed
  • 119. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> flashback table EMP to before drop; Flashback complete. 119
  • 120. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> flashback table EMP to before drop 2 rename to OLD_EMP; Flashback complete. 120
  • 121. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com indexes / constraints / triggers ... not renamed back
  • 122. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com how long ? 122
  • 123. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 1 second... ...10 years 123
  • 124. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> PURGE RECYCLEBIN; SQL> PURGE TABLE emp; SQL> PURGE TABLE "BIN$xyWe0+q+SniItJ0pn/u54A==$0"; SQL> PURGE TABLESPACE user1; SQL> PURGE INDEX "BIN$FTX34MN88J7==$0"; SQL> PURGE TABLESPACE user1 USER fred; 124
  • 125. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com no untruncate 125
  • 126. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback table 126
  • 127. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
  • 128. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback table 128
  • 129. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> FLASHBACK TABLE DEPT 2 TO TIMESTAMP TO_TIMESTAMP('2019-06-03 12:05:00') 129
  • 130. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com "undrop" 130
  • 131. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com "What's in it for me?" 131
  • 132. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com repeatable tests without cleanup scripts 132
  • 133. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com deletes modified rows since SCN inserts fresh rows as of SCN ... busy
  • 134. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> FLASHBACK TABLE DEPT 2 TO TIMESTAMP TO_TIMESTAMP('2019-06-03 12:05:00') 3 ENABLE TRIGGERS; 134
  • 135. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com rowid's change ... enable row movement 135
  • 136. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com indexes existence unaffected 136
  • 137. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com single transaction 137 ... multiple tables allowed
  • 138. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com tables locked 138
  • 139. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com R.I must still be valid 139
  • 140. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com statistics unchanged 140
  • 141. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com most DDL is a flashback boundary 141
  • 142. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> flashback table DEPT to scn ...; ORA-01466: unable to read data - table definition has changed 142
  • 143. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com each release gets better 143
  • 144. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> alter table DEPT add column XXX date; SQL> flashback table DEPT to scn ...; SQL> desc DEPT Name Null? Type -------------------------- -------- -------------- DEPTNO NUMBER(2) DNAME VARCHAR2(14) LOC VARCHAR2(13) XXX DATE 144
  • 145. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> flashback table DEPT to scn ...; ORA-08183: Flashback cannot be enabled in the middle of a transaction 145
  • 146. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback database 146
  • 147. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
  • 148. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
  • 149. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback database 149
  • 150. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | AUTHORISED DATABASE ADMINSTRATORS ONLY !
  • 151. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> alter database flashback on; Database altered. 151
  • 152. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 152 data changes "new" blocks to disk changes to disk "old" blocks to disk redo fbdadbwr
  • 153. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> FLASHBACK DATABASE TO '2:05PM' 153
  • 154. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> create restore point OK_SO_FAR; ... SQL> flashback database to restore point OK_SO_FAR; 154
  • 155. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com what does it cost ? 155
  • 156. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> desc V$FLASHBACK_DATABASE_STAT Name Null? Type ----------------------------- -------- --------- BEGIN_TIME DATE END_TIME DATE FLASHBACK_DATA NUMBER DB_DATA NUMBER REDO_DATA NUMBER ESTIMATED_FLASHBACK_SIZE NUMBER 156
  • 157. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com a good compromise 157
  • 158. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com guaranteed restore points 158
  • 159. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback logging "optional" 159
  • 160. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com less aggressive 160
  • 161. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com "What's in it for me?" 161
  • 162. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 1) safer deployment 162
  • 163. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com scenario: "My New Application" 163
  • 164. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 9:00 9:40 9:45 SQL> FLASHBACK DATABASE... 164 SQL> alter table ACCOUNTS ...
  • 165. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 2) repeatable end to end testing 165
  • 166. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 166
  • 167. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 12.2+ 167
  • 168. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback pluggable database 168
  • 169. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 3) production data for developers 169
  • 170. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com "hidden" example 170
  • 171. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com Data Guard 171
  • 172. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 172 5:00am 11:30pm standby recovery convert to snapshot revert to physical
  • 173. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback data archive 173
  • 174. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com less flashback, more archive 174
  • 175. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> CREATE FLASHBACK ARCHIVE longterm 2 TABLESPACE space_for_archive 3 RETENTION 1 YEAR; Flashback archive created. 175
  • 176. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> ALTER TABLE EMP FLASHBACK ARCHIVE LONGTERM; Table altered. [lots of DML on EMP] 176
  • 177. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select * from EMP; -------------------------------------------------- | Id | Operation | Name | Rows | Bytes | -------------------------------------------------- | 0 | SELECT STATEMENT | | 14 | 518 | | 1 | TABLE ACCESS FULL| EMP | 14 | 518 | -------------------------------------------------- 177
  • 178. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select * from EMP 2 AS OF TIMESTAMP SYSDATE-1/24; -------------------------------------------------- | Id | Operation | Name | Rows | Bytes | -------------------------------------------------- | 0 | SELECT STATEMENT | | 14 | 518 | | 1 | TABLE ACCESS FULL| EMP | 14 | 518 | -------------------------------------------------- 178
  • 179. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 3 days later... 179
  • 180. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select * from EMP 2 AS OF TIMESTAMP SYSDATE-3; ----------------------------------------------------------------- | Id | Operation | Name | Rows | ----------------------------------------------------------------- | 0 | SELECT STATEMENT | | 446 | | 1 | VIEW | | 446 | | 2 | UNION-ALL | | | |* 3 | FILTER | | | | 4 | PARTITION RANGE ITERATOR| | 445 | |* 5 | TABLE ACCESS FULL | SYS_FBA_HIST_69539 | 445 | |* 6 | FILTER | | | |* 7 | HASH JOIN OUTER | | 1 | |* 8 | TABLE ACCESS FULL | EMP | 1 | |* 9 | TABLE ACCESS FULL | SYS_FBA_TCRV_69539 | 14 | ------------------------------------------------------------------180
  • 181. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select table_name 2 from user_tables 3 / TABLE_NAME --------------------------- SYS_FBA_HIST_71036 SYS_FBA_TCRV_71036 SYS_FBA_DDL_COLMAP_71036 EMP 181
  • 182. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 182 note
  • 183. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 183 "The table does not use any of these Flashback Data Archive reserved words as column names: • STARTSCN • ENDSCN • RID • XID • OP • OPERATION"
  • 184. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com "What's in it for me?" 184
  • 185. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com "I don't care what EMP looked like last March..." 185
  • 186. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 186 why talk about it ?
  • 187. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 187 SQL> select * from EMP AS OF "JUNE"; SQL> select * from EMP AS OF "MARCH"; SQL> select * from EMP AS OF "2pm Wednesday"; SQL> select * from EMP AS OF etc etc etc
  • 188. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 188 every historical version...
  • 189. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 189 ... of every row
  • 190. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 190 sound familiar ?
  • 191. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 191 audit history
  • 192. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 192 we've all done it
  • 193. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 193 SQL> desc T Name Null? Type ------------------------ -------- ------------- OWNER NOT NULL VARCHAR2(30) OBJECT_NAME NOT NULL VARCHAR2(30) SQL> desc T_AUDIT Name Null? Type ------------------------ -------- -------------- AUDIT_DATE DATE AUDIT_ACTION CHAR(1) OWNER NOT NULL VARCHAR2(30) OBJECT_NAME NOT NULL VARCHAR2(30)
  • 194. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 194 SQL> create or replace 2 trigger AUDIT_TRG 3 after insert or update or delete on T 4 for each row 5 declare 6 v_action varchar2(1) := case when updating 7 then 'U' when deleting then 'D' else 'I' end; 8 begin 9 if updating or inserting then 10 insert into T_AUDIT 11 values (sysdate 12 ,v_action 13 ,:new.owner 14 ,:new.object_name); 15 else 16 insert into T_AUDIT 17 values (sysdate 18 ,v_action 19 ,:old.owner 20 ,:old.object_name); 21 end if; 22 end;
  • 195. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 195 works but slow...
  • 196. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 196 SQL> insert into T 2 select owner, object_name 3 from all_objects 4 where rownum <= 10000; 10000 rows created. insert into T select owner, object_name from all_objects where rownum <= 10000 call count cpu elapsed disk query current rows ------- ------ ------- ---------- -------- --------- ---------- ---------- Parse 1 0.01 0.00 0 0 0 0 Execute 1 3.10 3.05 88 123 10642 10000 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ ------- ---------- -------- --------- ---------- ---------- total 2 3.12 3.06 88 123 10642 10000 INSERT INTO T_AUDIT VALUES (SYSDATE ,:B3 ,:B1 ,:B2 ) call count cpu elapsed disk query current rows ------- ------ ------- ---------- -------- --------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 10000 0.79 0.97 2 109 10845 10000 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ ------- ---------- -------- --------- ---------- ---------- total 10001 0.79 0.97 2 109 10845 10000
  • 197. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com a better, faster, robust version ... 197
  • 198. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback data archive 198
  • 199. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select empno, ename, job, sal, comm, 2 nvl(VERSIONS_STARTTIME,LAST_MOD) TS 3 ,nvl(VERSIONS_OPERATION,'I') op 4 from EMP 5 versions between timestamp 6 timestamp '2019-02-11 20:12:00' and systimestamp 7 order by empno, ts; EMPNO ENAME JOB SAL COMM TS O ---------- ---------- --------- ---------- ---------- ------------ - 7369 SMITH CLERK 806 08.10.51 PM I 7369 SMITH SALES 8060 1000 08.12.10 PM U 7499 ALLEN SALESMAN 1606 300000000 08.10.51 PM I 7521 WARD SALESMAN 1256 500000000 08.10.51 PM I 7566 JONES MANAGER 2981 08.10.51 PM I ... 7900 JAMES CLERK 956 08.10.51 PM I 7902 FORD ANALYST 3006 08.10.51 PM I 7934 MILLER CLERK 1306 08.10.51 PM I 7934 MILLER CLERK 1306 08.12.10 PM D 199
  • 200. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com so why didn't we ? 200
  • 201. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com reason 1 201
  • 202. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com "yeah...but who ? where ? how ?" 202
  • 203. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> alter table EMP add UPDATED_BY varchar2(10); Table altered. SQL> alter table EMP add UPDATED_PGM varchar2(10); Table altered. [etc] 203
  • 204. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com reason 2 204
  • 205. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com
  • 206. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com separately licensed 206
  • 207. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 12c+ ... more options 207
  • 208. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 1) context extension 208
  • 209. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> begin 2 dbms_flashback_archive.set_context_level( 3 level=> 'ALL'); 4 end; PL/SQL procedure successfully completed. 209
  • 210. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> update EMP 2 set sal = sal*10 3 where empno = 7499; 1 row updated. SQL> commit; 210
  • 211. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select XID from SYS_FBA_HIST_510592; XID ---------------- 09000B00C7080000 211
  • 212. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> set serverout on SQL> begin 2 dbms_output.put_line( 3 dbms_flashback_archive.get_sys_context ( 4 '09000B00C7080000', 'USERENV', 'SESSION_USER')); 5 6 dbms_output.put_line( 7 dbms_flashback_archive.get_sys_context ( 8 '09000B00C7080000', 'USERENV', 'HOST')); 9 10 dbms_output.put_line( 11 dbms_flashback_archive.get_sys_context ( 12 '09000B00C7080000', 'USERENV', 'MODULE')); 13 end; 14 / SCOTT WORKGROUPXPS SQL*Plus 212
  • 213. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com ...and a few other things :-) 213
  • 214. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> desc SYS.SYS_FBA_CONTEXT_AUD Name Null? Type ------------------------- -------- ------------------ XID RAW(8) ACTION VARCHAR2(256) AUTHENTICATED_IDENTITY VARCHAR2(256) CLIENT_IDENTIFIER VARCHAR2(256) CLIENT_INFO VARCHAR2(256) CURRENT_EDITION_NAME VARCHAR2(256) CURRENT_SCHEMA VARCHAR2(256) CURRENT_USER VARCHAR2(256) DATABASE_ROLE VARCHAR2(256) DB_NAME VARCHAR2(256) GLOBAL_UID VARCHAR2(256) HOST VARCHAR2(256) IDENTIFICATION_TYPE VARCHAR2(256) INSTANCE_NAME VARCHAR2(256) IP_ADDRESS VARCHAR2(256) MODULE VARCHAR2(256) 214
  • 215. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> @pt "select * from SYS.SYS_FBA_CONTEXT_AUD where xid = '09000B00C7080000'" XID : 09000B00C7080000 AUTHENTICATED_IDENTITY : scott CLIENT_IDENTIFIER : CLIENT_INFO : CURRENT_EDITION_NAME : ORA$BASE CURRENT_SCHEMA : SYS CURRENT_USER : SYS DATABASE_ROLE : PRIMARY DB_NAME : np12 HOST : WORKGROUPXPS IDENTIFICATION_TYPE : LOCAL INSTANCE_NAME : np12 MODULE : SQL*Plus OS_USER : xpshamcdc SERVER_HOST : xps ... 215
  • 216. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select empno, ename, job, sal, comm, 2 VERSIONS_XID 3 from EMP 4 versions between timestamp 5 timestamp '2019-02-11 20:12:00' and systimestamp 6 order by empno; EMPNO ENAME JOB SAL COMM VERSIONS_XID ---------- ---------- --------- ---------- ---------- ---------------- 7369 SMITH CLERK 806 7369 SMITH SALES 8060 1000 09001C00E04A0000 7499 ALLEN CLERK 16060 300000000 0A000A0024080000 7499 ALLEN SALESMAN 16060 300000000 09000B00C7080000 7499 ALLEN SALESMAN 1606 300000000 7521 WARD SALESMAN 1256 500000000 216
  • 217. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select ... 2 from 3 ( select 4 empno, ename, job, 5 sal, comm, VERSIONS_XID 6 from EMP 7 versions between timestamp 8 timestamp '2019-02-11 20:12:00' and 9 systimestamp 10 ) e, SYS.SYS_FBA_CONTEXT_AUD a 11 where e.VERSIONS_XID = a.XID; 217
  • 218. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 2) price... 218
  • 219. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback data archive is now … 219
  • 220. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com 220
  • 221. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com not a typo 221
  • 222. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com basic versus advanced 222
  • 223. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com choose your cost compression 223
  • 224. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com so think about FDA 224
  • 225. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com secure read only 225
  • 226. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com efficient fdba 226
  • 227. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com all of your history... 227
  • 228. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com ... all of your audit 228
  • 229. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com "Where were you in 2004 ?!?!?" 229
  • 230. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com dbms_flashback_archive.import_history 230
  • 231. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com be careful ... silent errors 231
  • 232. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> ALTER TABLE EMP FLASHBACK ARCHIVE LONGTERM; Table altered. Flashback Archive: Error ORA-1950 in SQL create table "SCOTT".SYS_FBA_DDL_COLMAP_91938 (STARTSCN NUMBER, ENDSCN NUMBER... Flashback Archive: Error ORA-942 in SQL insert into "SCOTT".SYS_FBA_DDL_COLMAP_91938 (ENDSCN, COLUMN_NAME, TYPE, ... 232
  • 233. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com back to smon_scn_time 233
  • 234. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com CREATE TABLE "SYS"."SMON_SCN_TIME" ( "THREAD" NUMBER, "TIME_MP" NUMBER, "TIME_DP" DATE, "SCN_WRP" NUMBER, "SCN_BAS" NUMBER, "NUM_MAPPINGS" NUMBER, "TIM_SCN_MAP" RAW(1200), "SCN" NUMBER DEFAULT 0, "ORIG_THREAD" NUMBER DEFAULT 0 ) CLUSTER "SYS"."SMON_SCN_TO_TIME_AUX" ("THREAD") 234 2^16 = ~3.5 years
  • 235. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com "Recreate SMON_SCN_TIME as non-clustered table" Doc ID 2389804.1 235
  • 236. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com other stuff 236
  • 237. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com Session 1 Request Block 3217, SCN 4567192 Block 3217, SCN 4567234 "ABC" Block 3217, SCN 4567003, change ABC => XYZ undo segment block(s) No good..too new take a copy of the block Locate apply undo Block 3217, SCN 4567234 "ABC" Block 3217, SCN 4567234 "ABC" Block 3217, SCN 4567003 "XYZ" Block 3217, SCN 4567003 "XYZ" Session 2 update emp set ename = "ABC" where empno = 1234; commit; Done ! 237
  • 238. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com ORA_ROWSCN 238
  • 239. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> SELECT ORA_ROWSCN,empno,ename,sal 2 FROM emp; ORA_ROWSCN EMPNO ENAME SAL ---------- ---------- ---------- ---------- 1357038 7369 SMITH 800 1357038 7499 ALLEN 1600 1357038 7521 WARD 1250 1357038 7566 JONES 2975 1357038 7654 MARTIN 1250 1357038 7698 BLAKE 2850 1357038 7782 CLARK 2450 1357038 7788 SCOTT 3000 1357038 7839 KING 5000 1357038 7844 TURNER 1500 1357038 7876 ADAMS 1100 1357038 7900 JAMES 950 1357038 7902 FORD 3000 1357038 7934 MILLER 1300 239
  • 240. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com block level SCN 240
  • 241. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> UPDATE emp SET sal = 9999 2 WHERE empno = 7369; SQL> SELECT ORA_ROWSCN,empno,ename,sal 2 FROM emp; ORA_ROWSCN EMPNO ENAME SAL ---------- ---------- ---------- ---------- 1357484 7369 SMITH 9999 1357484 7499 ALLEN 1600 1357484 7521 WARD 1250 1357484 7566 JONES 2975 1357484 7654 MARTIN 1250 1357484 7698 BLAKE 2850 1357484 7782 CLARK 2450 1357484 7788 SCOTT 3000 1357484 7839 KING 5000 1357484 7844 TURNER 1500 1357484 7876 ADAMS 1100 1357484 7900 JAMES 950 1357484 7902 FORD 3000 1357484 7934 MILLER 1300 241
  • 242. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> CREATE TABLE newemp ROWDEPENDENCIES 2 AS SELECT * FROM emp; 242
  • 243. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> UPDATE newemp SET sal = 9999 2 WHERE empno = 7369 SQL> SELECT ORA_ROWSCN,empno,ename,sal 2 FROM newemp; ORA_ROWSCN EMPNO ENAME SAL ---------- ---------- ---------- ---------- 1357558 7369 SMITH 9999 1357545 7499 ALLEN 1600 1357545 7521 WARD 1250 1357545 7566 JONES 2975 1357545 7654 MARTIN 1250 1357545 7698 BLAKE 2850 1357545 7782 CLARK 2450 1357545 7788 SCOTT 3000 1357545 7839 KING 5000 1357545 7844 TURNER 1500 1357545 7876 ADAMS 1100 1357545 7900 JAMES 950 1357545 7902 FORD 3000 1357545 7934 MILLER 1300 243
  • 244. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com SQL> select ORA_ROWSCN, SCN_TO_TIMESTAMP(ORA_ROWSCN) 2 FROM emp 3 WHERE ... 244
  • 245. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com wrap up 245
  • 246. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com flashback query flashback table flashback drop flashback database flashback transaction flashback data archive
  • 247. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com all included in EE 247
  • 248. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com all cool for modern development 248
  • 249. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | @connor_mc_dconnor-mcdonald.com That's a wrap! youtube bit.ly/youtube-connor blog bit.ly/blog-connor twitter bit.ly/twitter-connor