2.Create index online:
Session 1
SQL> drop index idx_text01;
SQL> alter session set events '10704 trace name context forever, level 12';
SQL> create index idx_text_ol on text_t1(OBJECT_ID) online;
Session 2
新窗口观察V$LOCK中的会话持有锁动态
SQL> select * from v$lock where sid=45;
ADDR KADDR SID TY ID1 ID2 LMODE REQUEST CTIME BLOCK
---------------- ---------------- ---------- -- ---------- ---------- ---------- ---------- ---------- ----------
00000000BED5CD78 00000000BED5CDD0 45 DL 89012 0 3 0 45 0
00000000BED5CE58 00000000BED5CEB0 45 AE 100 0 4 0 11379 0
00000000BED5D398 00000000BED5D3F0 45 DL 89012 0 3 0 45 0
00000000BED5D478 00000000BED5D4D0 45 OD 89012 0 4 0 45 0
00007F2A281DA3A8 00007F2A281DA408 45 TM 89012 0 2 0 45 0
00007F2A281DA3A8 00007F2A281DA408 45 TM 89042 0 4 0 45 0
00000000BBE04B08 00000000BBE04BB8 45 TS 14 25597834 6 0 7 0
00000000BBF03CC8 00000000BBF03D40 45 TX 65555 1310 6 0 45 0
00000000BBF44768 00000000BBF447E0 45 TX 65562 1294 6 0 7 0
SQL> select object_name from dba_objects where object_id=89042;
OBJECT_NAME
--------------------------------------------------------------------------------------------------------------------------------
SYS_JOURNAL_89041 Create index online执行过程中会创建一个临时对象,并在执行结束前删除对象和释放锁。
Session 1
SQL> create index idx_text_ol on text_t1(OBJECT_ID) online;
Index created.
SQL> alter session set events '10704 trace name context off';
Linux
[oracle@localhost trace]$ more orcl_ora_55118.trc 从OS从提取日志分析
TM-00015bb4-00000000 mode=2 指向TEXT_T1 开头持有结尾释放。持有2号TM锁,不阻塞DML操作
TM-00015bd2-00000000 mode=4 指向SYS_JOURNAL_89041临时对象
TM-00000012-00000000 mode=3 指向OBJ$ 持有再释放,首尾两次
TM-0000001c-00000000 mode=3 指向CON$ 持有再释放,首尾两次
TM-0000000e-00000000 mode=3 指向SEG$ 持有再释放 重复九次
TM-00000014-00000000 mode=3 指向ICOL$ 持有再释放 重复四次
TM-00000013-00000000 mode=3 指向IND$ 持有再释放 重复四次
TM-00000004-00000000 mode=3 指向TAB$ 持有再释放 首尾两次
TM-00000015-00000000 mode=3 指向COL$ 持有再释放 重复两次
TM-00000020-00000000 mode=3 指向CCOL$ 持有再释放 重复两次
TM-0000001f-00000000 mode=3 指向CDEF$ 持有再释放 重复两次
TM-00000092-00000000 mode=3 指向IND_ONLINE$ 持有再释放 重复三次
TM-000001c7-00000000 mode=3 指向IND_STATS$ 持有再释放 重复三次
TM-000001eb-00000000 mode=3 指向WRI$_OPTSTAT_IND_HISTORY
TM-000137d9-00000000 mode=3 指向SDO_GEOR_DDL__TABLE$$
TM-000000db-00000000 mode=3 指向OBJECT_USAGE
TM-000001c9-00000000 mode=3 指向CACHE_STATS_1$
TM-00000089-00000000 mode=3 指向COM$
TM-000001c0-00000000 mode=3 指向HIST_HEAD$
TM-000000b6-00000000 mode=3 指向TRANSIENT_IOT$
TM-00000282-00000000 mode=3 指向SUMDELTA$
TM-0000027f-00000000 mode=3 指向SUMPARTLOG$
TM-00000286-00000000 mode=3 指向SNAP_LOADERTIME$
TM-000137d9-00000000 mode=3 指向SDO_GEOR_DDL__TABLE$$
TM-000000e1-00000000 mode=3 指向IDL_UB1$
TM-000000e2-00000000 mode=3 指向IDL_CHAR$
TM-000000e3-00000000 mode=3 指向IDL_UB2$
TM-000000e4-00000000 mode=3 指向IDL_SB4$
TM-000000f2-00000000 mode=3 指向NCOMP_DLL$
TM-0000003d-00000000 mode=3 指向OBJAUTH$
TM-00000072-00000000 mode=3 指向ICOLDEP$
TM-00000097-00000000 mode=3 指向JIJOIN$
TM-0000009b-00000000 mode=3 指向JIREFRESHSQL$
TM-0000007b-00000000 mode=3 指向ECOL$
TM-00000053-00000000 mode=3 指向COLTYPE$
TM-00000056-00000000 mode=3 指向SUBCOLTYPE$
TM-00000058-00000000 mode=3 指向NTAB$
TM-00000050-00000000 mode=3 指向LOB$
TM-0000005c-00000000 mode=3 指向REFCON$
TM-0000005f-00000000 mode=3 指向OPQTYPE$