|
1. session 3°³ (hr/hr, hr/hr, sys/oracle as sysdba)¸¦ open ÇÑ´Ù.
-hr/hr (session 1)
$sqlplus hr/hr
SQL> update temp_emps set salary = salary*1.1
2 where salary < 15000;
$ sqlplus 'sys/oracle as sysdba'
SQL> select sid,type,id1,id2,lmode,request
2 from v$lock
3 where type in('TX','TM')
4 ;
SID TY ID1 ID2 LMODE REQUEST
---------- -- ---------- ---------- ---------- ----------
11 TX 196624 1442 6 0
11 TM 8202 0 3 0
* LMODE : 0 :none
2 : Row shace : for shared DML Locks
4 : share : ITL entry ¿¡ ´ëÇÑ waiting ½Ã
6 : Exclusive : row level, DML Locks
ID1 : DML lock ÀÇ °æ¿ì ´ë»ó object id
: TX lockÀÇ °æ¿ì Rollback segment ¿Í Transaction Table À» point
- º°µµÀÇ hr/hr sessionÀ» open ÇÑ´Ù. -hr (session 3)
$ sqlplus hr/hr
SQL> drop table hr.temp_emps;
drop table hr.temp_emps
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified
*** DDLÀº Exclusive table lock À» ÇÊ¿ä·Î ÇÑ´Ù. ÀÌÀüÀÇ hr/hr session 1¿¡¼ temp_emps ¿¡ ´ëÇØ ¸ÕÀú Exclusive row table lock À» °É°í ÀÖÀ¸¹Ç·Î ÀÌ drop Àº exclusive table lockÀ» ȹµæÇÒ
¼ö ¾øÀ¸¹Ç·Î ½ÇÆÐÇÑ´Ù.
SQL> update temp_emps set salary = salary * 1.5
2 where salary > 15000;
-sys/oracle as sysdba sessionÀ¸·Î À̵¿
SQL> select sid,type,id1,id2,lmode,request
2 from v$lock
3 where id1 = (select object_id from dba_objects where object_name = 'TEMP_EMPS' and object_type = 'TABLE');
SID TY ID1 ID2 LMODE REQUEST
---------- -- ---------- ---------- ---------- ----------
11 TM 8202 0 3 0
15 TM 8202 0 3 0
- µÎ¹ø° hr/hr session (session 3)¿¡¼
SQL> rollback;
SQL> update hr.temp_emps set manager_id=10
2 where salary < 15000; <--- Hang!
-sys/oracle as sysdba session ¿¡¼ (session 2)
SQL> select sid,type,id1,id2,lmode,request
2 from v$lock
3 where id1 = (select object_id from dba_objects where object_name = 'TEMP_EMPS' and object_type = 'TABLE');
SID TY ID1 ID2 LMODE REQUEST
---------- -- ---------- ---------- ---------- ----------
11 TM 8202 0 3 0
15 TM 8202 0 3 0
SQL> @/opt/oracle/product/9.2.0/rdbms/admin/catblock.sql
SQL> select holding_session,waiting_session
2 from dba_waiters;
HOLDING_SESSION WAITING_SESSION
--------------- ---------------
11 15
SQL> select sid,serial#,username from v$session
2 where sid='11';
SID SERIAL# USERNAME
---------- ---------- ------------------------------
11 5 HR
SQL> alter system kill session '11,5';
-ù¹ø° hr/hr session(session 1) À¸·Î À̵¿ÇÏ¿©
SQL> select * from temp_emps;
select * from temp_emps
*
ERROR at line 1:
ORA-00028: your session has been killed
¸ðµç sessionÀ» exit
SQL> exit
SQL> exit
SQL> exit
|