Bo's Oracle Station

【博客文章2021】在Flashback Transaction中处理事务的依赖关系和主键外键约束

2021-11-3 15:40| 发布者: admin| 查看: 1| 评论: 0|原作者: Bo Tang

摘要: 【博客文章2021】在Flashback Transaction操作中处理事务的依赖关系和主键外键约束Author: Bo Tang1.补充日志:select d.LOG_MODE, d.SUPPLEMENTAL_LOG_DATA_MIN, d.SUPPLEMENTAL_LOG_DATA_PK, d.SUPPLEMENTAL_LOG_DATA_FKfrom v_$database d;复制代码 LOG_MODESUPPLEMENTAL_LOG_DATA_MINSUPPLEMENTAL_LOG_
【博客文章2021】在Flashback Transaction操作中处理事务的依赖关系和主键外键约束

Author: Bo Tang


1.  补充日志:
  1. select d.LOG_MODE,
  2.            d.SUPPLEMENTAL_LOG_DATA_MIN,
  3.            d.SUPPLEMENTAL_LOG_DATA_PK,
  4.            d.SUPPLEMENTAL_LOG_DATA_FK
  5. from v_$database d;
复制代码
   LOG_MODESUPPLEMENTAL_LOG_DATA_MINSUPPLEMENTAL_LOG_DATA_PKSUPPLEMENTAL_LOG_DATA_FK
1ARCHIVELOGNONONO

  1. alter database add supplemental log data;

  2. alter database add supplemental  log data ( primary  key ) columns ;
复制代码
 t05310.sql (388 Bytes, 下载次数: 340)

  1. select  ftq.xid,ftq.commit_scn ,ftq.operation ,ftq.undo_sql
  2. from flashback_transaction_query ftq
  3. where ftq.table_owner='HR'
  4. and ftq.table_name='T_NOCASCADE'
  5. order by ftq.commit_scn   ;
复制代码
   XIDCOMMIT_SCNOPERATIONUNDO_SQL
109002100890600002377212INSERTdelete from "HR"."T_NOCASCADE" where ROWID = 'AAAT4GAAEAAAAIfAAB';
209002100890600002377212INSERTdelete from "HR"."T_NOCASCADE" where ROWID = 'AAAT4GAAEAAAAIfAAA';
309002100890600002377212INSERTdelete from "HR"."T_NOCASCADE" where ROWID = 'AAAT4GAAEAAAAIfAAC';
40A001000C30500002377217UPDATEupdate "HR"."T_NOCASCADE" set "ID" = '3' where ROWID = 'AAAT4GAAEAAAAIfAAC';
50A001000C30500002377217UPDATEupdate "HR"."T_NOCASCADE" set "ID" = '1' where ROWID = 'AAAT4GAAEAAAAIfAAA';
60A001000C30500002377217UPDATEupdate "HR"."T_NOCASCADE" set "ID" = '2' where ROWID = 'AAAT4GAAEAAAAIfAAB';
7010020000C0600002377221UPDATEupdate "HR"."T_NOCASCADE" set "ID" = '22' where ROWID = 'AAAT4GAAEAAAAIfAAB';
8010020000C0600002377221UPDATEupdate "HR"."T_NOCASCADE" set "ID" = '33' where ROWID = 'AAAT4GAAEAAAAIfAAC';
905001400410700002377224UPDATEupdate "HR"."T_NOCASCADE" set "ID" = '222' where ROWID = 'AAAT4GAAEAAAAIfAAB';

  1. begin
  2.   dbms_flashback.transaction_backout(numtxns => 1,
  3.   xids => xid_array('0A001000C3050000'),
  4.   options => dbms_flashback.nocascade);
  5. end;
复制代码


  1. begin
  2.   dbms_flashback.transaction_backout(numtxns => 1,
  3.   xids => xid_array('0A001000C3050000'),
  4.   options => dbms_flashback.cascade);
  5. end;

  6. select  * from dba_flashback_txn_report;
复制代码
   COMPENSATING_XIDCOMPENSATING_TXN_NAMECOMMIT_TIMEXID_REPORTUSERNAME
106002100C8060000<CLOB>SYS

CLOB:
<?xml version="1.0" encoding="ISO-8859-1"?>
<COMP_XID_REPORT XID="06002100C8060000">
    <TRANSACTION XID="0A001000C3050000">
    <CHARACTERISTICS>
    </CHARACTERISTICS>
    <UNDO_SQL>
        <USQL exec="yes">
         update "HR"."T_NOCASCADE" set "ID" = '3' where "ID" = '33' and ROWID = 'AAAT4GAAEAAAAIfAAC'
        </USQL>
        <USQL exec="yes">
         update "HR"."T_NOCASCADE" set "ID" = '2' where "ID" = '22' and ROWID = 'AAAT4GAAEAAAAIfAAB'
        </USQL>
        <USQL exec="yes">
         update "HR"."T_NOCASCADE" set "ID" = '1' where "ID" = '11' and ROWID = 'AAAT4GAAEAAAAIfAAA'
        </USQL>
    </UNDO_SQL>
    <DEPENDENT_XIDS>
        <TRANSACTION XID="010020000C060000">
        <CHARACTERISTICS>
        </CHARACTERISTICS>
        <UNDO_SQL>
            <USQL exec="yes">
             update "HR"."T_NOCASCADE" set "ID" = '33' where "ID" = '333' and ROWID = 'AAAT4GAAEAAAAIfAAC'
            </USQL>
            <USQL exec="yes">
             update "HR"."T_NOCASCADE" set "ID" = '22' where "ID" = '222' and ROWID = 'AAAT4GAAEAAAAIfAAB'
            </USQL>
        </UNDO_SQL>
        <DEPENDENT_XIDS>
            <TRANSACTION XID="0500140041070000">
            <CHARACTERISTICS>
            </CHARACTERISTICS>
            <UNDO_SQL>
                <USQL exec="yes">
                 update "HR"."T_NOCASCADE" set "ID" = '222' where "ID" = '22' and ROWID = 'AAAT4GAAEAAAAIfAAB'
                </USQL>
            </UNDO_SQL>
            <DEPENDENT_XIDS>
            </DEPENDENT_XIDS>
            </TRANSACTION>
        </DEPENDENT_XIDS>
        </TRANSACTION>
    </DEPENDENT_XIDS>
    </TRANSACTION>
<EXECUTED_UNDO_SQL>
<EXEC_USQL>update "HR"."T_NOCASCADE" set "ID" = '222' where "ID" = '22' and ROWID = 'AAAT4GAAEAAAAIfAAB'
</EXEC_USQL>
<EXEC_USQL>update "HR"."T_NOCASCADE" set "ID" = '33' where "ID" = '333' and ROWID = 'AAAT4GAAEAAAAIfAAC'
</EXEC_USQL>
<EXEC_USQL>update "HR"."T_NOCASCADE" set "ID" = '22' where "ID" = '222' and ROWID = 'AAAT4GAAEAAAAIfAAB'
</EXEC_USQL>
<EXEC_USQL>update "HR"."T_NOCASCADE" set "ID" = '3' where "ID" = '33' and ROWID = 'AAAT4GAAEAAAAIfAAC'
</EXEC_USQL>
<EXEC_USQL>update "HR"."T_NOCASCADE" set "ID" = '2' where "ID" = '22' and ROWID = 'AAAT4GAAEAAAAIfAAB'
</EXEC_USQL>
<EXEC_USQL>update "HR"."T_NOCASCADE" set "ID" = '1' where "ID" = '11' and ROWID = 'AAAT4GAAEAAAAIfAAA'
</EXEC_USQL>
</EXECUTED_UNDO_SQL>
</COMP_XID_REPORT>
---------------------------

commit;
SQL> select * from t_nocascade;

    ID
----------
     1
     2
     3
-----------------------------------------------------------------------------------------------------------------------------------------------------
  1. select  ftq.xid,ftq.commit_scn ,ftq.operation ,ftq.undo_sql
  2. from flashback_transaction_query ftq
  3. where ftq.table_owner='HR'
  4. and ftq.table_name='T_NOCASCADE_FORCE'
  5. order by ftq.commit_scn   ;
复制代码
   XIDCOMMIT_SCNOPERATIONUNDO_SQL
107001F00040600002381390INSERTdelete from "HR"."T_NOCASCADE_FORCE" where ROWID = 'AAAT4MAAEAAAAInAAA';
207001F00040600002381390INSERTdelete from "HR"."T_NOCASCADE_FORCE" where ROWID = 'AAAT4MAAEAAAAInAAB';
307001F00040600002381390INSERTdelete from "HR"."T_NOCASCADE_FORCE" where ROWID = 'AAAT4MAAEAAAAInAAC';
40A001C00A70500002381395UPDATEupdate "HR"."T_NOCASCADE_FORCE" set "ID" = '2' where ROWID = 'AAAT4MAAEAAAAInAAB';
50A001C00A70500002381395UPDATEupdate "HR"."T_NOCASCADE_FORCE" set "ID" = '1' where ROWID = 'AAAT4MAAEAAAAInAAA';
60A001C00A70500002381395UPDATEupdate "HR"."T_NOCASCADE_FORCE" set "ID" = '3' where ROWID = 'AAAT4MAAEAAAAInAAC';
704001600120600002381399UPDATEupdate "HR"."T_NOCASCADE_FORCE" set "ID" = '22' where ROWID = 'AAAT4MAAEAAAAInAAB';
804001600120600002381399UPDATEupdate "HR"."T_NOCASCADE_FORCE" set "ID" = '33' where ROWID = 'AAAT4MAAEAAAAInAAC';
909000400B70600002381402UPDATEupdate "HR"."T_NOCASCADE_FORCE" set "ID" = '222' where ROWID = 'AAAT4MAAEAAAAInAAB';

  1. begin
  2.   dbms_flashback.transaction_backout(numtxns => 1,
  3.   xids => xid_array('0A001C00A7050000'),
  4.   options => dbms_flashback.nocascade_force);
  5. end;

  6. select  * from dba_flashback_txn_report;
复制代码
   COMPENSATING_XIDCOMPENSATING_TXN_NAMECOMMIT_TIMEXID_REPORTUSERNAME
106002100C80600008/10/2018 8:08:13 PM<CLOB>SYS
202000700B0060000_SYS_COMP_TXN_13173587_TIM_1533903232<CLOB>SYS
CLOB:
<?xml version="1.0" encoding="ISO-8859-1"?>
<COMP_XID_REPORT XID="02000700B0060000" NAME="_SYS_COMP_TXN_13173587_TIM_1533903232">
    <TRANSACTION XID="0A001C00A7050000">
    <CHARACTERISTICS>
    </CHARACTERISTICS>
    <UNDO_SQL>
        <USQL exec="yes">
         update "HR"."T_NOCASCADE_FORCE" set "ID" = '3' where "ID" = '33' and ROWID = 'AAAT4MAAEAAAAInAAC'
        </USQL>
        <USQL exec="yes">
         update "HR"."T_NOCASCADE_FORCE" set "ID" = '2' where "ID" = '22' and ROWID = 'AAAT4MAAEAAAAInAAB'
        </USQL>
        <USQL exec="yes">
         update "HR"."T_NOCASCADE_FORCE" set "ID" = '1' where "ID" = '11' and ROWID = 'AAAT4MAAEAAAAInAAA'
        </USQL>
    </UNDO_SQL>
    <DEPENDENT_XIDS>
        <TRANSACTION XID="0400160012060000">
        <CHARACTERISTICS>
        </CHARACTERISTICS>
        <UNDO_SQL>
            <USQL exec="no">
             update "HR"."T_NOCASCADE_FORCE" set "ID" = '33' where "ID" = '333' and ROWID = 'AAAT4MAAEAAAAInAAC'
            </USQL>
            <USQL exec="no">
             update "HR"."T_NOCASCADE_FORCE" set "ID" = '22' where "ID" = '222' and ROWID = 'AAAT4MAAEAAAAInAAB'
            </USQL>
        </UNDO_SQL>
        <DEPENDENT_XIDS>
            <TRANSACTION XID="09000400B7060000">
            <CHARACTERISTICS>
            </CHARACTERISTICS>
            <UNDO_SQL>
                <USQL exec="no">
                 update "HR"."T_NOCASCADE_FORCE" set "ID" = '222' where "ID" = '22' and ROWID = 'AAAT4MAAEAAAAInAAB'
                </USQL>
            </UNDO_SQL>
            <DEPENDENT_XIDS>
            </DEPENDENT_XIDS>
            </TRANSACTION>
        </DEPENDENT_XIDS>
        </TRANSACTION>
    </DEPENDENT_XIDS>
    </TRANSACTION>
<EXECUTED_UNDO_SQL>
<EXEC_USQL>update "HR"."T_NOCASCADE_FORCE" set "ID" = '3' where "ID" = '33' and ROWID = 'AAAT4MAAEAAAAInAAC'
</EXEC_USQL>
<EXEC_USQL>update "HR"."T_NOCASCADE_FORCE" set "ID" = '2' where "ID" = '22' and ROWID = 'AAAT4MAAEAAAAInAAB'
</EXEC_USQL>
<EXEC_USQL>update "HR"."T_NOCASCADE_FORCE" set "ID" = '1' where "ID" = '11' and ROWID = 'AAAT4MAAEAAAAInAAA'
</EXEC_USQL>
</EXECUTED_UNDO_SQL>
</COMP_XID_REPORT>
------------
commit;
SQL> select * from t_nocascade_force;

    ID
----------
     1
     2
       333

----------------------------------------------------------------------------------------------------
  1. select  ftq.xid,ftq.commit_scn ,ftq.operation ,ftq.undo_sql
  2. from flashback_transaction_query ftq
  3. where ftq.table_owner='HR'
  4. and ftq.table_name='T_NONCONFLICT_ONLY'
  5. order by ftq.commit_scn   ;
复制代码
   XIDCOMMIT_SCNOPERATIONUNDO_SQL
10A002000C50500002384313INSERTdelete from "HR"."T_NONCONFLICT_ONLY" where ROWID = 'AAAT4NAAEAAAAIvAAC';
20A002000C50500002384313INSERTdelete from "HR"."T_NONCONFLICT_ONLY" where ROWID = 'AAAT4NAAEAAAAIvAAA';
30A002000C50500002384313INSERTdelete from "HR"."T_NONCONFLICT_ONLY" where ROWID = 'AAAT4NAAEAAAAIvAAB';
401001600150600002384318UPDATEupdate "HR"."T_NONCONFLICT_ONLY" set "ID" = '2' where ROWID = 'AAAT4NAAEAAAAIvAAB';
501001600150600002384318UPDATEupdate "HR"."T_NONCONFLICT_ONLY" set "ID" = '1' where ROWID = 'AAAT4NAAEAAAAIvAAA';
601001600150600002384318UPDATEupdate "HR"."T_NONCONFLICT_ONLY" set "ID" = '3' where ROWID = 'AAAT4NAAEAAAAIvAAC';
703001600940600002384322UPDATEupdate "HR"."T_NONCONFLICT_ONLY" set "ID" = '33' where ROWID = 'AAAT4NAAEAAAAIvAAC';
803001600940600002384322UPDATEupdate "HR"."T_NONCONFLICT_ONLY" set "ID" = '22' where ROWID = 'AAAT4NAAEAAAAIvAAB';
9040014001C0600002384325UPDATEupdate "HR"."T_NONCONFLICT_ONLY" set "ID" = '222' where ROWID = 'AAAT4NAAEAAAAIvAAB';

  1. begin
  2.   dbms_flashback.transaction_backout(numtxns => 1,
  3.   xids => xid_array('0100160015060000'),
  4.   options => dbms_flashback.nonconflict_only);
  5. end;

  6. select  * from dba_flashback_txn_report;
复制代码
   COMPENSATING_XIDCOMPENSATING_TXN_NAMECOMMIT_TIMEXID_REPORTUSERNAME
106002100C80600008/10/2018 8:08:13 PM<CLOB>SYS
202000700B0060000_SYS_COMP_TXN_13173587_TIM_15339032328/10/2018 8:18:57 PM<CLOB>SYS
302001700B1060000_SYS_COMP_TXN_13173587_TIM_1533904147<CLOB>SYS

CLOB:
<?xml version="1.0" encoding="ISO-8859-1"?>
<COMP_XID_REPORT XID="02001700B1060000" NAME="_SYS_COMP_TXN_13173587_TIM_1533904147">
    <TRANSACTION XID="0100160015060000">
    <CHARACTERISTICS>
    </CHARACTERISTICS>
    <UNDO_SQL>
        <USQL exec="no">
         update "HR"."T_NONCONFLICT_ONLY" set "ID" = '3' where "ID" = '33' and ROWID = 'AAAT4NAAEAAAAIvAAC'
        </USQL>
        <USQL exec="no">
         update "HR"."T_NONCONFLICT_ONLY" set "ID" = '2' where "ID" = '22' and ROWID = 'AAAT4NAAEAAAAIvAAB'
        </USQL>
        <USQL exec="yes">
         update "HR"."T_NONCONFLICT_ONLY" set "ID" = '1' where "ID" = '11' and ROWID = 'AAAT4NAAEAAAAIvAAA'
        </USQL>
    </UNDO_SQL>
    <DEPENDENT_XIDS>
        <TRANSACTION XID="0300160094060000">
        <CHARACTERISTICS>
        </CHARACTERISTICS>
        <UNDO_SQL>
            <USQL exec="no">
             update "HR"."T_NONCONFLICT_ONLY" set "ID" = '33' where "ID" = '333' and ROWID = 'AAAT4NAAEAAAAIvAAC'
            </USQL>
            <USQL exec="no">
             update "HR"."T_NONCONFLICT_ONLY" set "ID" = '22' where "ID" = '222' and ROWID = 'AAAT4NAAEAAAAIvAAB'
            </USQL>
        </UNDO_SQL>
        <DEPENDENT_XIDS>
            <TRANSACTION XID="040014001C060000">
            <CHARACTERISTICS>
            </CHARACTERISTICS>
            <UNDO_SQL>
                <USQL exec="no">
                 update "HR"."T_NONCONFLICT_ONLY" set "ID" = '222' where "ID" = '22' and ROWID = 'AAAT4NAAEAAAAIvAAB'
                </USQL>
            </UNDO_SQL>
            <DEPENDENT_XIDS>
            </DEPENDENT_XIDS>
            </TRANSACTION>
        </DEPENDENT_XIDS>
        </TRANSACTION>
    </DEPENDENT_XIDS>
    </TRANSACTION>
<EXECUTED_UNDO_SQL>
<EXEC_USQL>update "HR"."T_NONCONFLICT_ONLY" set "ID" = '1' where "ID" = '11' and ROWID = 'AAAT4NAAEAAAAIvAAA'
</EXEC_USQL>
</EXECUTED_UNDO_SQL>
</COMP_XID_REPORT>
----------------------------------------------------------------------------------------------------------------------
commit;
SQL> select * from t_nonconflict_only;

    ID
----------
     1
    22
       333
----------------------------------------------------------------------------------------------------
 t05310simple.sql (344 Bytes, 下载次数: 337)

----------------------------------------------------------主键约束依赖关系:
  1. SQL> create table t_parent( a  number primary key  ) ;

  2. Table created.

  3. SQL> insert into t_parent  values (1) ;

  4. 1 row created.

  5. SQL> commit;

  6. Commit complete.

  7. SQL> delete from  t_parent where a=1;

  8. 1 row deleted.

  9. SQL> commit;

  10. Commit complete.

  11. SQL> insert into t_parent  values (1) ;

  12. 1 row created.

  13. SQL> commit;

  14. Commit complete.
复制代码
  1. select  ftq.xid,ftq.commit_scn ,ftq.operation ,ftq.undo_sql
  2. from flashback_transaction_query ftq
  3. where ftq.table_owner='HR'
  4. and ftq.table_name='T_PARENT'
  5. order by ftq.commit_scn   ;

  6. begin
  7.   dbms_flashback.transaction_backout(numtxns => 1,
  8.   xids => xid_array('02000700B3060000'),
  9.   options => dbms_flashback.nocascade_force);
  10. end;
复制代码

   XIDCOMMIT_SCNOPERATIONUNDO_SQL
1070017000B0600002389627INSERTdelete from "HR"."T_PARENT" where ROWID = 'AAAT4QAAEAAAAJHAAA';
202000700B30600002389635DELETEinsert into "HR"."T_PARENT"("A") values ('1');
307001B000B0600002389663INSERTdelete from "HR"."T_PARENT" where ROWID = 'AAAT4QAAEAAAAJHAAB';



  1. begin
  2.   dbms_flashback.transaction_backout(numtxns => 1,
  3.   xids => xid_array('02000700B3060000'),
  4.   options => dbms_flashback.nonconflict_only);
  5. end;

  6. select  * from dba_flashback_txn_report;
复制代码
   COMPENSATING_XIDCOMPENSATING_TXN_NAMECOMMIT_TIMEXID_REPORTUSERNAME
106002100C80600008/10/2018 8:08:13 PM<CLOB>SYS
202000700B0060000_SYS_COMP_TXN_13173587_TIM_15339032328/10/2018 8:18:57 PM<CLOB>SYS
302001700B1060000_SYS_COMP_TXN_13173587_TIM_15339041478/10/2018 8:34:23 PM<CLOB>SYS
40100020017060000_SYS_COMP_TXN_13173587_TIM_15339046958/10/2018 8:39:03 PM<CLOB>SYS
509001E00B5060000_SYS_COMP_TXN_13173587_TIM_15339048558/10/2018 8:41:38 PM<CLOB>SYS
606001400CD060000<CLOB>SYS
CLOB:
<?xml version="1.0" encoding="ISO-8859-1"?>
<COMP_XID_REPORT XID="06001400CD060000">
    <TRANSACTION XID="02000700B3060000">
    <CHARACTERISTICS>
    </CHARACTERISTICS>
    <UNDO_SQL>
        <USQL exec="no">
         insert into "HR"."T_PARENT"("A") values ('1')
        </USQL>
    </UNDO_SQL>
    <DEPENDENT_XIDS>
        <TRANSACTION XID="07001B000B060000">
        <CHARACTERISTICS>
        </CHARACTERISTICS>
        <UNDO_SQL>
            <USQL exec="no">
             delete from "HR"."T_PARENT" where "A" = '1'
            </USQL>
        </UNDO_SQL>
        <DEPENDENT_XIDS>
        </DEPENDENT_XIDS>
        </TRANSACTION>
    </DEPENDENT_XIDS>
    </TRANSACTION>
<EXECUTED_UNDO_SQL>
</EXECUTED_UNDO_SQL>
</COMP_XID_REPORT>

------------------------------------------
  1. begin
  2.   dbms_flashback.transaction_backout(numtxns => 1,
  3.   xids => xid_array('02000700B3060000'),
  4.   options => dbms_flashback.cascade);
  5. end;

  6. select  * from dba_flashback_txn_report;
复制代码
   COMPENSATING_XIDCOMPENSATING_TXN_NAMECOMMIT_TIMEXID_REPORTUSERNAME
106002100C80600008/10/2018 8:08:13 PM<CLOB>SYS
202000700B0060000_SYS_COMP_TXN_13173587_TIM_15339032328/10/2018 8:18:57 PM<CLOB>SYS
302001700B1060000_SYS_COMP_TXN_13173587_TIM_15339041478/10/2018 8:34:23 PM<CLOB>SYS
40100020017060000_SYS_COMP_TXN_13173587_TIM_15339046958/10/2018 8:39:03 PM<CLOB>SYS
509001E00B5060000_SYS_COMP_TXN_13173587_TIM_15339048558/10/2018 8:41:38 PM<CLOB>SYS
609000F00B5060000_SYS_COMP_TXN_13173587_TIM_1533906837<CLOB>SYS

CLOB:
<?xml version="1.0" encoding="ISO-8859-1"?>
<COMP_XID_REPORT XID="09000F00B5060000" NAME="_SYS_COMP_TXN_13173587_TIM_1533906837">
    <TRANSACTION XID="02000700B3060000">
    <CHARACTERISTICS>
    </CHARACTERISTICS>
    <UNDO_SQL>
        <USQL exec="yes">
         insert into "HR"."T_PARENT"("A") values ('1')
        </USQL>
    </UNDO_SQL>
    <DEPENDENT_XIDS>
        <TRANSACTION XID="07001B000B060000">
        <CHARACTERISTICS>
        </CHARACTERISTICS>
        <UNDO_SQL>
            <USQL exec="yes">
             delete from "HR"."T_PARENT" where "A" = '1'
            </USQL>
        </UNDO_SQL>
        <DEPENDENT_XIDS>
        </DEPENDENT_XIDS>
        </TRANSACTION>
    </DEPENDENT_XIDS>
    </TRANSACTION>
<EXECUTED_UNDO_SQL>
<EXEC_USQL>delete from "HR"."T_PARENT" where "A" = '1'
</EXEC_USQL>
<EXEC_USQL>insert into "HR"."T_PARENT"("A") values ('1')
</EXEC_USQL>
</EXECUTED_UNDO_SQL>
</COMP_XID_REPORT>

  1. select  ftq.xid,ftq.commit_scn ,ftq.operation ,ftq.undo_sql
  2. from flashback_transaction_query ftq
  3. where ftq.table_owner='HR'
  4. and ftq.table_name='T_PARENT'
  5. order by ftq.commit_scn   ;
复制代码
   XIDCOMMIT_SCNOPERATIONUNDO_SQL
1070017000B0600002389627INSERTdelete from "HR"."T_PARENT" where ROWID = 'AAAT4QAAEAAAAJHAAA';
202000700B30600002389635DELETEinsert into "HR"."T_PARENT"("A") values ('1');
307001B000B0600002389663INSERTdelete from "HR"."T_PARENT" where ROWID = 'AAAT4QAAEAAAAJHAAB';
409000F00B5060000DELETEinsert into "HR"."T_PARENT"("A") values ('1');
509000F00B5060000INSERTdelete from "HR"."T_PARENT" where ROWID = 'AAAT4QAAEAAAAJDAAA';
-------------------------------------------------------------------------------------------------------------------------------------------------------------外键约束依赖关系:
  1. SQL> create table t_p ( a  number primary key ) ;

  2. Table created.

  3. SQL> insert into t_p VALUES (1) ;

  4. 1 row created.

  5. SQL> commit;

  6. Commit complete.

  7. SQL> create table t_s ( a  number referencing t_p ) ;

  8. Table created.

  9. SQL> insert into t_s values ( 2);
  10. insert into t_s values ( 2)
  11. *
  12. ERROR at line 1:
  13. ORA-02291: integrity constraint (HR.SYS_C0015123) violated - parent key not
  14. found


  15. SQL> insert into  t_s values (1) ;

  16. 1 row created.

  17. SQL> commit;

  18. Commit complete.

  19. SQL>
复制代码
  1. select  ftq.xid,ftq.commit_scn ,ftq.operation ,ftq.undo_sql,ftq.table_name
  2. from flashback_transaction_query ftq
  3. where ftq.table_owner='HR'
  4. and ftq.table_name in ('T_P','T_S')
  5. order by ftq.commit_scn   ;

  6. begin
  7.   dbms_flashback.transaction_backout(numtxns => 2,
  8.   xids => xid_array('07000B000D060000','0400110021060000'),
  9.   options => dbms_flashback.cascade);
  10. end;
复制代码
由于没有外建补充日志:



  1. alter database add supplemental log data  (foreign key) columns;
复制代码
  1. SQL>  create table t_p2 ( a  number primary key ) ;

  2. Table created.

  3. SQL> insert into t_p2 VALUES (1) ;

  4. 1 row created.

  5. SQL> commit;

  6. Commit complete.

  7. SQL> create table t_s2  ( a  number referencing t_p2 );

  8. Table created.

  9. SQL> insert into t_s2 values (1) ;

  10. 1 row created.

  11. SQL> commit;

  12. Commit complete.

  13. SQL>
复制代码
  1. select  ftq.xid,ftq.commit_scn ,ftq.operation ,ftq.undo_sql,ftq.table_name
  2. from flashback_transaction_query ftq
  3. where ftq.table_owner='HR'
  4. and ftq.table_name in ('T_P2','T_S2')
  5. order by ftq.commit_scn   ;
复制代码
   XIDCOMMIT_SCNOPERATIONUNDO_SQLTABLE_NAME
108000F00370600002394322INSERTdelete from "HR"."T_P2" where ROWID = 'AAAT4VAAEAAAAJ/AAA';T_P2
203000E009B0600002394396INSERTdelete from "HR"."T_S2" where ROWID = 'AAAT4XAAEAAAAKHAAA';T_S2

  1.   1  select  ftq.xid,ftq.commit_scn ,ftq.operation ,ftq.undo_sql,ftq.table_name
  2.   2   from flashback_transaction_query ftq
  3.   3   where ftq.table_owner='HR'
  4.   4   and ftq.table_name in ('T_P','T_S')
  5.   5*  order by ftq.commit_scn
  6. SQL> /

  7. XID                 COMMIT_SCN OPERATION                             UNDO_SQL                                                                              TABLE_NAME
  8. ---------------- ---------- -------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  9. 04000E0005120000    4977399 INSERT                             delete from "HR"."T_P" where ROWID = 'AAAoBkAAEAAAAC1AAA';                       T_P
  10. 0C0011002A090000    4977585 INSERT                             delete from "HR"."T_S" where ROWID = 'AAAoBmAAEAAAADFAAA';                       T_S

  11. begin
  12.   dbms_flashback.transaction_backout(numtxns => 1,
  13.   xids => xid_array('04000E0005120000'),
  14.   options => dbms_flashback.cascade);
  15.   5  end;
  16.   6  /

  17. PL/SQL procedure successfully completed.

  18. SQL> set long 10000
  19. SQL> select  * from dba_flashback_txn_report;

  20. COMPENSATING_XID COMPENSATING_TXN_NAME                                                                                                          COMMIT_TIME             XID_REPORT                                                                       USERNAME
  21. ---------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------ -------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------
  22. 0900180015120000 _SYS_COMP_TXN_75674175_TIM_1533908729                                                                                             <?xml version="1.0" encoding="ISO-8859-1"?>                                      SYS
  23.                                                                                                                                              <COMP_XID_REPORT XID="0900180015120000" NAME="_SYS_COMP_
  24.                                                                                                                                              TXN_75674175_TIM_1533908729">
  25.                                                                                                                                                      <TRANSACTION XID="04000E0005120000">
  26.                                                                                                                                                      <CHARACTERISTICS>
  27.                                                                                                                                                      </CHARACTERISTICS>
  28.                                                                                                                                                      <UNDO_SQL>
  29.                                                                                                                                                              <USQL exec="yes">
  30.                                                                                                                                                               delete from "HR"."T_P" where "A" = '1'

  31.                                                                                                                                                              </USQL>

  32. COMPENSATING_XID COMPENSATING_TXN_NAME                                                                                                          COMMIT_TIME             XID_REPORT                                                                       USERNAME
  33. ---------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------ -------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------
  34.                                                                                                                                                      </UNDO_SQL>
  35.                                                                                                                                                      <DEPENDENT_XIDS>
  36.                                                                                                                                                              <TRANSACTION XID="0C0011002A090000">
  37.                                                                                                                                                              <CHARACTERISTICS>
  38.                                                                                                                                                              </CHARACTERISTICS>
  39.                                                                                                                                                              <UNDO_SQL>
  40.                                                                                                                                                                      <USQL exec="yes">
  41.                                                                                                                                                                       delete from "HR"."T_S" where "A" = '1' a
  42.                                                                                                                                              nd ROWID = 'AAAoBmAAEAAAADFAAA'
  43.                                                                                                                                                                      </USQL>
  44.                                                                                                                                                              </UNDO_SQL>

  45. COMPENSATING_XID COMPENSATING_TXN_NAME                                                                                                          COMMIT_TIME             XID_REPORT                                                                       USERNAME
  46. ---------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------ -------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------
  47.                                                                                                                                                              <DEPENDENT_XIDS>
  48.                                                                                                                                                              </DEPENDENT_XIDS>
  49.                                                                                                                                                              </TRANSACTION>
  50.                                                                                                                                                      </DEPENDENT_XIDS>
  51.                                                                                                                                                      </TRANSACTION>
  52.                                                                                                                                              <EXECUTED_UNDO_SQL>
  53.                                                                                                                                              <EXEC_USQL>delete from "HR"."T_S" where "A" = '1' an
  54.                                                                                                                                              d ROWID = 'AAAoBmAAEAAAADFAAA'
  55.                                                                                                                                              </EXEC_USQL>
  56.                                                                                                                                              <EXEC_USQL>delete from "HR"."T_P" where "A" = '1'
  57.                                                                                                                                              </EXEC_USQL>

  58. COMPENSATING_XID COMPENSATING_TXN_NAME                                                                                                          COMMIT_TIME             XID_REPORT                                                                       USERNAME
  59. ---------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------ -------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------
  60.                                                                                                                                              </EXECUTED_UNDO_SQL>
  61.                                                                                                                                              </COMP_XID_REPORT>



  62. SQL>
复制代码



路过

雷人

握手

鲜花

鸡蛋

QQ|手机版|Bo's Oracle Station   

GMT+8, 2022-4-11 15:46 , Processed in 0.048624 second(s), 21 queries .

返回顶部