Bo's Oracle Station

查看: 2416|回复: 0

课程第56次(2017-09-22星期五)

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2017-9-22 21:17:54 | 显示全部楼层 |阅读模式
第三阶段New Feature/OCM Exam Preparation31-56
  1. select  ftq.xid, ftq.table_name, ftq.operation, ftq.undo_sql
  2. from flashback_transaction_query ftq
  3. where ftq.logon_user='HR'
  4. order by ftq.start_scn desc;

  5.   begin
  6.      dbms_flashback.transaction_backout (
  7.      numtxns => 1,
  8.      xids =>  xid_array('03001500D3050000'),
  9.      options => dbms_flashback.nocascade);
  10.    end;
  11.      
  12.    alter database add supplemental log data;
  13.    
  14.    select  d.SUPPLEMENTAL_LOG_DATA_MIN,
  15.               d.SUPPLEMENTAL_LOG_DATA_PK,
  16.               d.SUPPLEMENTAL_LOG_DATA_FK
  17.     from v_$database d;
  18.      
  19.     ----
  20.     select  ftq.xid, ftq.table_name, ftq.operation, ftq.undo_sql
  21. from flashback_transaction_query ftq
  22. where ftq.logon_user='HR'  and ftq.table_name='T_NOCASCADE2'
  23. order by ftq.start_scn desc;

  24. ---0100180051050000
  25. begin
  26.      dbms_flashback.transaction_backout (
  27.      numtxns => 1,
  28.      xids =>  xid_array('0100180051050000'),
  29.      options => dbms_flashback.nocascade);
  30.    end;
  31. ---
  32. select  ftq.xid, ftq.table_name, ftq.operation, ftq.undo_sql
  33. from flashback_transaction_query ftq
  34. where ftq.logon_user='HR'  and ftq.table_name='T_CASCADE'
  35. order by ftq.start_scn desc;

  36. ---09000700F1050000  ---0A000D00FD040000
  37. begin
  38.      dbms_flashback.transaction_backout (
  39.      numtxns => 1,
  40.      xids =>  xid_array('09000700F1050000'),
  41.      options => dbms_flashback.cascade);
  42.    end;
  43.    ---
  44.    select  * from dba_flashback_txn_report;
  45.    
  46.    select  * from dba_flashback_txn_state;
  47.    commit;
  48.    
  49.    ----
  50.    select  ftq.xid, ftq.table_name, ftq.operation, ftq.undo_sql
  51. from flashback_transaction_query ftq
  52. where ftq.logon_user='HR'  and ftq.table_name='T_NOCASCADE_FORCE'
  53. order by ftq.start_scn desc;

  54. ---0700130049050000  ---04001A0057050000
  55. begin
  56.      dbms_flashback.transaction_backout (
  57.      numtxns => 1,
  58.      xids =>  xid_array('0700130049050000'),
  59.      options => dbms_flashback.nocascade_force);
  60.    end;
  61.    ---
  62.    select  * from dba_flashback_txn_report;
  63.    
  64.    select  * from dba_flashback_txn_state;
  65.    commit;
  66.    
  67.    ----
  68.     ----
  69.    select  ftq.xid, ftq.table_name, ftq.operation, ftq.undo_sql
  70. from flashback_transaction_query ftq
  71. where ftq.logon_user='HR'  and ftq.table_name='T_NONCONFLICT_ONLY'
  72. order by ftq.start_scn desc;

  73. ---02001900F1050000  ---04001A0057050000
  74. begin
  75.      dbms_flashback.transaction_backout (
  76.      numtxns => 1,
  77.      xids =>  xid_array('02001900F1050000'),
  78.      options => dbms_flashback.nonconflict_only);
  79.    end;
  80.    ---
  81.    select  * from dba_flashback_txn_report;
  82.    
  83.    select  * from dba_flashback_txn_state;
  84.    commit;
  85.    ---
  86.    select  ftq.xid, ftq.table_name, ftq.operation, ftq.undo_sql
  87. from flashback_transaction_query ftq
  88. where ftq.logon_user='HR'  and ftq.table_name='S_NOCASCADE_FORCE'
  89. order by ftq.start_scn desc;

  90. ---02001F00F4050000

  91. begin
  92.      dbms_flashback.transaction_backout (
  93.      numtxns => 1,
  94.      xids =>  xid_array('02001F00F4050000'),
  95.      options => dbms_flashback.nocascade_force
  96.      
  97.      );
  98.    end;
  99.       select  * from dba_flashback_txn_report;
  100.    commit;
  101.    
复制代码
  1. SQL> select  * from t_nocascade;

  2.         ID
  3. ----------
  4.         11
  5.         22
  6.        333

  7. SQL> select  * from t_cascade;

  8.         ID
  9. ----------
  10.          1
  11.          2
  12.          3

  13. SQL> select  * from t_nocascade_force;

  14.         ID
  15. ----------
  16.          1
  17.          2
  18.        333

  19. SQL> select  * from t_nonconflict_only;

  20.         ID
  21. ----------
  22.          1
  23.         22
  24.        333
复制代码
  1. SQL> select  * from s_nocascade;

  2.         ID
  3. ----------
  4.         11
  5.        222
  6.        333


  7. SQL> select  * from s_cascade;

  8.         ID
  9. ----------
  10.          1
  11.          2
  12.          3

  13. SQL> select  * from s_nocascade_force;

  14.         ID
  15. ----------
  16.          1
  17.        222
  18.        333


  19. SQL> select  * from s_nonconflict_only;

  20.         ID
  21. ----------
  22.          1
  23.        222
  24.        333
复制代码
  1. SQL> create table t_pk ( a  number primary key  )  ;

  2. Table created.

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

  4. 1 row created.

  5. SQL> commit;

  6. Commit complete.

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

  8. 1 row deleted.

  9. SQL> commit;

  10. Commit complete.

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

  12. 1 row created.

  13. SQL> commit;

  14. Commit complete.

  15. SQL> select  * from t_pk;

  16.          A
  17. ----------
  18.          1

  19. SQL>
复制代码

Screenshot.png

  1. SQL>  create table t_pk2 ( a  number primary key  )  ;

  2. Table created.

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

  4. 1 row created.

  5. SQL> commit;

  6. Commit complete.

  7. SQL>
  8. SQL> delete from t_pk2 where a=1;

  9. 1 row deleted.

  10. SQL> commit;

  11. Commit complete.

  12. SQL> insert into t_pk2  values (1) ;

  13. 1 row created.

  14. SQL> commit;

  15. Commit complete.

  16. SQL> select  * from t_pk2;

  17.          A
  18. ----------
  19.          1
复制代码


Screenshot-1.png

  1. SQL>  create table t_pk3 ( a  number primary key  )  ;

  2. Table created.

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

  4. 1 row created.

  5. SQL> commit;

  6. Commit complete.

  7. SQL> create table t_pk3_son ( a  number refreneces t_pk3 ) ;
  8. create table t_pk3_son ( a  number refreneces t_pk3 )
  9.                                    *
  10. ERROR at line 1:
  11. ORA-00907: missing right parenthesis


  12. SQL> create table t_pk3_son ( a  number references t_pk3 ) ;

  13. Table created.

  14. SQL> insert into t_pk3_son values (2) ;
  15. insert into t_pk3_son values (2)
  16. *
  17. ERROR at line 1:
  18. ORA-02291: integrity constraint (HR.SYS_C0014932) violated - parent key not
  19. found


  20. SQL> insert into t_pk3_son values (1) ;

  21. 1 row created.

  22. SQL> commit;

  23. Commit complete.

  24. SQL>
复制代码
  1. select  ftq.xid, ftq.table_name, ftq.operation, ftq.undo_sql
  2. from flashback_transaction_query ftq
  3. where ftq.logon_user='HR'  and ftq.table_name='T_PK4'
  4. order by ftq.start_scn desc;

  5. ---04000A005E050000

  6. begin
  7.      dbms_flashback.transaction_backout (
  8.      numtxns => 1,
  9.      xids =>  xid_array('02000A00F5050000'),
  10.      options => dbms_flashback.cascade   
  11.      );
  12.    end;
  13.    
  14.       select  * from dba_flashback_txn_report;
  15.    commit;
  16.    ---
  17.     select  d.SUPPLEMENTAL_LOG_DATA_MIN,
  18.               d.SUPPLEMENTAL_LOG_DATA_PK,
  19.               d.SUPPLEMENTAL_LOG_DATA_FK
  20.     from v_$database d;
  21.    
  22.     ---
  23.     alter database add supplemental log data ( foreign key  ) columns;
  24.    
复制代码

<?xml version="1.0" encoding="ISO-8859-1"?>
<COMP_XID_REPORT XID="02000400D2050000" NAME="_SYS_COMP_TXN_4456479_TIM_1506087917">
    <TRANSACTION XID="02000A00F5050000">
    <CHARACTERISTICS>
    </CHARACTERISTICS>
    <UNDO_SQL>
        <USQL exec="yes">
         delete from "HR"."T_PK4" where "A" = '1'
        </USQL>
    </UNDO_SQL>
    <DEPENDENT_XIDS>
        <TRANSACTION XID="0800070067050000">
        <CHARACTERISTICS>
        </CHARACTERISTICS>
        <UNDO_SQL>
            <USQL exec="yes">
             delete from "HR"."T_PK4_SON" where "A" = '1' and ROWID = 'AAATrpAAEAAAAKcAAA'
            </USQL>
        </UNDO_SQL>
        <DEPENDENT_XIDS>
        </DEPENDENT_XIDS>
        </TRANSACTION>
    </DEPENDENT_XIDS>
    </TRANSACTION>
<EXECUTED_UNDO_SQL>
<EXEC_USQL>delete from "HR"."T_PK4_SON" where "A" = '1' and ROWID = 'AAATrpAAEAAAAKcAAA'
</EXEC_USQL>
<EXEC_USQL>delete from "HR"."T_PK4" where "A" = '1'
</EXEC_USQL>
</EXECUTED_UNDO_SQL>
</COMP_XID_REPORT>

  1. SQL> select  * from t_pk4_son;

  2. no rows selected

  3. SQL> select  * from t_pk4;

  4. no rows selected

复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-11-22 00:18 , Processed in 0.043729 second(s), 28 queries .

快速回复 返回顶部 返回列表