SQL> select sql_text from v$sql where sql_id='7qqwcq9td6akt';
SQL_TEXT ---------------------------------------------------------------------- delete test
SQL> alter system kill session '30,165' immediate;
System altered.
--回到原來窗口驗(yàn)證: SQL> select count(*) from test; select count(*) from test * ERROR at line 1: ORA-03135: connection lost contact Process ID: 28346 Session ID: 30 Serial number: 165
二、定位: 查看回滾進(jìn)度: 可以通過以下兩個視圖查看回滾的進(jìn)度,通過單位時間內(nèi)恢復(fù)的undo block來估算恢復(fù)時間: 1. 通過x$ktuxe alter session set nls_date_format='yyyy-mm-dd hh34:mi:ss'; select ADDR,KTUXEUSN,KTUXESLT,KTUXESQN,KTUXESIZ,sysdate from x$ktuxe where KTUXECFL='DEAD' and KTUXESIZ >0;
SQL> alter session set nls_date_format='yyyy-mm-dd hh34:mi:ss';
Session altered.
SQL> select ADDR,KTUXEUSN,KTUXESLT,KTUXESQN,KTUXESIZ,sysdate from x$ktuxe where KTUXECFL='DEAD' and KTUXESIZ >0;
可以通過KTUXESLT ,KTUXESQN這兩個字段,然后用以下腳本回滾得出大概需要的時間: set serveroutput on declare l_start number; l_end number; begin select ktuxesiz into l_start from x$ktuxe where KTUXEUSN = 5 and KTUXESLT = 11; dbms_lock.sleep(60); select ktuxesiz into l_end from x$ktuxe where KTUXEUSN = 5 and KTUXESLT = 11; dbms_output.put_line('time est Day:' || round(l_end / (l_start - l_end) / 60 / 24, 2)); end; /
time est Day:.01
PL/SQL procedure successfully completed.
SQL> SQL>
2. 通過v$fast_start_trancsations 狀態(tài)為recovering表示恢復(fù)中; select USN,SLT,SEQ,STATE,UNDOBLOCKSDONE,UNDOBLOCKSTOTAL,CPUTIME,XID,sysdate from V$FAST_START_TRANSACTIONS;
SQL> select USN,SLT,SEQ,STATE,UNDOBLOCKSDONE,UNDOBLOCKSTOTAL,CPUTIME,XID,sysdate from V$FAST_START_TRANSACTIONS;
USN SLT SEQ STATE UNDOBLOCKSDONE UNDOBLOCKSTOTAL CPUTIME XID SYSDATE ---------- ---------- ---------- ---------------- -------------- --------------- ---------- ---------------- ------------------- 5 11 7784 RECOVERING 123491 179829 120 05000B00681E0000 2017-12-09 14:20:25 通過如下視圖觀察回滾是串行還是并行回滾的,如下圖應(yīng)是并行恢復(fù)的, V$FAST_START_SERVERS provides information about all the recovery slaves performing parallel transaction recovery.
通過xid字段與v$fast_start_trancsations關(guān)聯(lián)。 select * from v$fast_start_servers where xid in (select XID from V$FAST_START_TRANSACTIONS);
SQL> select * from v$fast_start_servers where xid in (select XID from V$FAST_START_TRANSACTIONS);