OracleÅÌÎʱíËø״̬µÄÊÊÓü¼ÇÉ
OracleÊÇÒ»¿îÇ¿Ê¢µÄ¹ØϵÐÍÊý¾Ý¿âÖÎÀíϵͳ£¬ËüÌṩÁ˸»ºñµÄ¹¦Ð§ÒÔ¼°ÎÞаµÄÅÌÎÊÓïÑÔ¡£ÔÚÈÕ³£¿ª·¢ºÍÔËάÀú³ÌÖУ¬ÎÒÃǾ³£»áÓöµ½ÅÌÎʱíËø״̬µÄÐèÇó¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃOracleµÄϵͳÊÓͼÀ´ÅÌÎʱíËø״̬£¬²¢¸ø³öÏêϸµÄ´úÂëʾÀý¡£
ÔÚOracleÖУ¬±íËøÊÇÓÃÀ´¿ØÖƲ¢·¢»á¼ûµÄÖ÷Òª»úÖÆ¡£µ±Ò»¸ö»á»°¶Ô±í¾ÙÐиüвÙ×÷ʱ£¬ÏµÍ³»á×Ô¶¯ÔڸñíÉϼÓËø£¬±ÜÃâÆäËû»á»°¶ÔͳһÐоÙÐв¢·¢¸üУ¬´Ó¶øÈ·±£Êý¾ÝµÄÒ»ÖÂÐÔºÍÍêÕûÐÔ¡£
ÒªÅÌÎʱíËø״̬£¬¿ÉÒÔͨ¹ýOracleÌṩµÄϵͳÊÓͼÀ´ÊµÏÖ¡£ÆäÖУ¬×î³£ÓõÄÊÇV$LOCKºÍV$LOCKED_OBJECT¡£
V$LOCKÊÓͼ°üÀ¨ÁËÄ¿½ñÊý¾Ý¿âÖеÄËùÓÐËøÐÅÏ¢£¬°üÀ¨ËøÀàÐÍ¡¢Ëø¶¨¹¤¾ß¡¢ËøµÄ³ÖÓÐÕߵȡ£¿ÉÒÔͨ¹ýÅÌÎʸÃÊÓͼÀ´»ñÈ¡Ä¿½ñÊý¾Ý¿âÖеÄËùÓбíËøÐÅÏ¢¡£
V$LOCKED_OBJECTÊÓͼÔò°üÀ¨ÁËÄ¿½ñÕýÔÚ±»Ëø¶¨µÄ¹¤¾ßÐÅÏ¢£¬°üÀ¨±»ËøµÄ¹¤¾ßID¡¢±íÃû¡¢Ä£Ê½ÃûµÈ¡£¿ÉÒÔͨ¹ýÅÌÎʸÃÊÓͼÀ´»ñÈ¡Ä¿½ñÕýÔÚ±»Ëø¶¨µÄ±íÐÅÏ¢¡£
ÏÂÃæÊÇÒ»¸ö¼òÆӵĴúÂëʾÀý£¬ÑÝʾÔõÑùÅÌÎʱíËø״̬£º
-- ÅÌÎÊÄ¿½ñÊý¾Ý¿âÖеÄËùÓбíËøÐÅÏ¢ SELECT l.session_id, l.locked_mode, l.lock_type, l.block, o.object_name, s.os_user_name FROM v$lock l, dba_objects o, v$session s WHERE l.type = 'TM' AND l.id1 = o.object_id AND l.sid = s.sid; -- ÅÌÎÊÄ¿½ñÕýÔÚ±»Ëø¶¨µÄ±íÐÅÏ¢ SELECT lo.session_id, lo.object_id, lo.object_name, o.owner, s.os_user_name FROM v$locked_object lo, dba_objects o, v$session s WHERE lo.object_id = o.object_id AND lo.session_id = s.sid;
µÇ¼ºó¸´ÖÆ
ͨ¹ýÒÔÉÏ´úÂëʾÀý£¬ÎÒÃÇ¿ÉÒÔÇåÎúµØÏàʶĿ½ñÊý¾Ý¿âÖеıíËø״̬£¬°üÀ¨ÄÄЩ±í±»Ëø¶¨¡¢±»ÄÄЩ»á»°³ÖÓеÈÐÅÏ¢¡£ÕâЩÐÅÏ¢¿ÉÒÔ×ÊÖúÎÒÃǸüºÃµØ¶¨Î»²¢·¢»á¼ûµÄÎÊÌ⣬Ìá¸ßϵͳµÄÐÔÄܺÍÎȹÌÐÔ¡£
×ܵÄÀ´Ëµ£¬ÅÌÎÊOracle±íËø״̬µÄ¼¼Çɲ¢²»ÖØ´ó£¬Í¨¹ýϵͳÊÓͼºÍSQLÅÌÎÊ£¬ÎÒÃÇ¿ÉÒÔÇáËɵػñÈ¡µ½ËùÐèµÄÐÅÏ¢¡£Ï£Íû±¾ÎÄÄܹ»×ÊÖú¶ÁÕ߸üºÃµØÃ÷È·ºÍÓ¦ÓÃOracleÊý¾Ý¿âÖеıíËø»úÖÆ¡£
ÒÔÉϾÍÊÇOracleÅÌÎʱíËø״̬µÄÊÊÓü¼ÇɵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡