|
- SQL> select uvalue from t04209_uname where uname='g1';
- UVALUE
- ----------
- 1
- SQL> update t04209_uname set uvalue=2 where uname='g1';
- 1 row updated.
- SQL> commit;
- Commit complete.
- SQL> update t04209_uname set uvalue=3 where uname='g1';
- 1 row updated.
- SQL> commit;
- Commit complete.
- SQL> update t04209_uname set uvalue=4 where uname='g1';
- 1 row updated.
- SQL> commit;
- Commit complete.
- SQL> update t04209_uname set uvalue=5 where uname='g1';
- 1 row updated.
- SQL> commit;
- Commit complete.
- SQL>
复制代码- select * from dba_rollback_segs;
- select * from v$transaction;
- --1000190010000000
- select * from flashback_transaction_query ftq
- where ftq.xid='1000190010000000';
-
- select * from flashback_transaction_query ftq
- where ftq.logon_user='HR' and ftq.table_name='T04209_UNAME';
-
- select count(*) from flashback_transaction_query;
复制代码
| XID | START_SCN | START_TIMESTAMP | COMMIT_SCN | COMMIT_TIMESTAMP | LOGON_USER | UNDO_CHANGE# | OPERATION | TABLE_NAME | TABLE_OWNER | ROW_ID | UNDO_SQL | 1 | 0C00160014000000 | 1165592 | 2019/6/22 9:03:27 | 1166044 | 2019/6/22 9:12:07 | HR | 1 | UNKNOWN | T04209_UNAME | | | | 2 | 1000190010000000 | 0 | 2019/6/22 9:11:08 | 1165965 | 2019/6/22 9:10:19 | HR | 1 | UNKNOWN | T04209_UNAME | | | | 3 | 1100120016000000 | 1166057 | 2019/6/22 9:12:37 | 1166070 | 2019/6/22 9:12:52 | HR | 1 | UNKNOWN | T04209_UNAME | | | | 4 | 1400120015000000 | 1166044 | 2019/6/22 9:12:07 | 1166057 | 2019/6/22 9:12:37 | HR | 1 | UNKNOWN | T04209_UNAME | | | |
- select
- versions_xid,
- versions_operation,
- versions_startscn,
- to_char(versions_starttime, 'YYYY-MM-DD:HH24:MI:SS'),
- uvalue
- from hr.t04209_uname
- versions between scn minvalue and maxvalue
- where uname='g1';
复制代码
| VERSIONS_XID | VERSIONS_OPERATION | VERSIONS_STARTSCN | TO_CHAR(VERSIONS_STARTTIME,'YY | UVALUE | 1 | 1100120016000000 | U | 1166070 | 2019-06-22:09:12:52 | 5 | 2 | 1400120015000000 | U | 1166057 | 2019-06-22:09:12:37 | 4 | 3 | 0C00160014000000 | U | 1166044 | 2019-06-22:09:12:07 | 3 | 4 | 1000190010000000 | U | 1165965 | 2019-06-22:09:10:19 | 2 | 5 | | | | | 1 |
闪回表的时候,除了值要对,位置也要对,所以需要行移动(因为有可能,现在要闪回的位置被别人占领了!)
- SQL> create table t05310_c ( a number ) ;
- Table created.
- SQL> insert into t05310_c values (1) ;
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> update t05310_c set a=2 ;
- 1 row updated.
- SQL> commit;
- Commit complete.
- SQL> alter table t05310_c add ( b varchar2(20)) ;
- Table altered.
- SQL> select * from t05310_c ;
- A B
- ---------- --------------------
- 2
- SQL> select * from t05310_c ;
- A B
- ---------- --------------------
- 1
- SQL>
复制代码 闪回表操作,本身是删除+插入的组合,如果DDL有增加字段,闪回到过去,会拖着新加的字段显示。
- select versions_xid, versions_startscn , versions_operation, a from hr.t05310_c
- versions between scn minvalue and maxvalue
- order by versions_startscn
- ;
复制代码
| VERSIONS_XID | VERSIONS_STARTSCN | VERSIONS_OPERATION | A | 1 | 12000F001E000000 | 1172963 | I | 1 | 2 | 110016001E000000 | 1172979 | U | 2 | 3 | 110020001F000000 | 1173527 | D | 2 | 4 | 110020001F000000 | 1173527 | I | 1 | -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
如何让闪回事务查询显示无遮挡的信息(operation/table_owner/rowid/undo_sql),可以考虑打开补充日志。
- select d.SUPPLEMENTAL_LOG_DATA_MIN,
- d.SUPPLEMENTAL_LOG_DATA_PK,
- d.SUPPLEMENTAL_LOG_DATA_UI,
- d.SUPPLEMENTAL_LOG_DATA_FK,
- d.SUPPLEMENTAL_LOG_DATA_ALL
- from v_$database d;
-
- alter database add supplemental log data;
复制代码
|
|