OracleÅÌÎʱíËø״̬ҪÁìÏê½â
OracleÅÌÎʱíËø״̬ҪÁìÏê½â
ÔÚÊý¾Ý¿â²Ù×÷ÖУ¬±íËøÊÇÒ»¸öºÜÊÇÖ÷ÒªµÄ¿´·¨£¬Ëû»áÓ°Ïìµ½Êý¾Ý¿âµÄÐÔÄܺͲ¢·¢¶È¡£±¾ÎĽ«ÏêϸÏÈÈÝÔÚOracleÊý¾Ý¿âÖÐÅÌÎʱíËø״̬µÄÒªÁ죬²¢¸ø³öÏêϸµÄ´úÂëʾÀý¡£
1. ÅÌÎʱíËø״̬µÄÒªÁì
ÔÚOracleÊý¾Ý¿âÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ýÔÚϵͳÊÓͼÖÐÅÌÎÊÀ´»ñÈ¡±íËø״̬ÐÅÏ¢¡£ÏÂÃæÊÇһЩ³£ÓõÄϵͳÊÓͼ£º
V$LOCK£ºÏÔʾÊý¾Ý¿âÖи߼¶ËøÐÅÏ¢µÄÊÓͼ
DBA_BLOCKERS£ºÏÔʾĿ½ñµÄ»á»°IDºÍËø¶¨»á»°ID
DBA_WAITERS£ºÏÔʾĿ½ñµÄ»á»°IDºÍÆÚ´ý»á»°ID
DBA_DML_LOCKS£ºÏÔʾĿ½ñ»á»°³ÖÓкÍÆÚ´ýµÄDMLËøÐÅÏ¢
2. Ïêϸ´úÂëʾÀý
2.1 ÅÌÎʱíÉϵÄËø¶¨»á»°
SELECT c.object_name, b.sid, b.serial#, b.username, b.status, b.server, l.locked_mode, l.lock_type FROM v$locked_object l, dba_objects c, v$session b WHERE l.object_id = c.object_id AND l.session_id = b.sid;
µÇ¼ºó¸´ÖÆ
Õâ¶Î´úÂë¿ÉÒÔÅÌÎʳöÄ¿½ñÊý¾Ý¿âÖи÷¸ö±íµÄËø¶¨»á»°ÐÅÏ¢£¬°üÀ¨»á»°ID¡¢³ÖÓÐËøµÄÓû§¡¢ËøÀàÐ͵ȡ£
2.2 ÅÌÎÊÄ¿½ñ»á»°µÄÆÚ´ýºÍ³ÖÓеÄËøÐÅÏ¢
SELECT session_id, lock_type, mode_held, mode_requested FROM dba_dml_locks UNION SELECT holding_session session_id, holding_cursor_type lock_type, MODE_HELD mode_held, MODE_REQUESTED mode_requested FROM dba_kgl_locks
µÇ¼ºó¸´ÖÆ
Õâ¶Î´úÂë¿ÉÒÔÅÌÎÊÄ¿½ñ»á»°³ÖÓкÍÆÚ´ýµÄËøÐÅÏ¢£¬¿ÉÒÔ×ÊÖúÎÒÃǸüºÃµØÃ÷È·Ä¿½ñÊý¾Ý¿âÖÐËøµÄÏêϸÇéÐΡ£
3. ×ܽá
ͨ¹ýÒÔÉϵÄÏÈÈÝ£¬ÎÒÃÇÏàʶÁËÔÚOracleÊý¾Ý¿âÖÐÅÌÎʱíËø״̬µÄÒªÁ죬²¢¸ø³öÁËÏêϸµÄ´úÂëʾÀý¡£ÔÚÏÖʵ²Ù×÷ÖУ¬Í¨¹ý¼à¿Ø±íËø״̬£¬ÎÒÃÇ¿ÉÒÔ¸üºÃµØÓÅ»¯Êý¾Ý¿âµÄÐÔÄÜ£¬Ìá¸ßϵͳµÄ²¢·¢´¦ÀíÄÜÁ¦¡£Ï£Íû±¾ÎĶÔÄúÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊÇOracleÅÌÎʱíËø״̬ҪÁìÏê½âµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡