Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¹ØÓÚoracleµÄÐм¶Ëø

¹ØÓÚoracleµÄÐм¶Ëø
¡¡¡¡ÔÚoracleÖÐ,Ðм¶ËøÖ»¶ÔÓû§ÕýÔÚ·ÃÎʵÄÐнøÐÐËø¶¨¡£
¡¡¡¡Èç¹û¸ÃÓû§ÕýÔÚÐÞ¸ÄijÐУ¬ÄÇôÆäËûÓû§¾Í¿ÉÒÔ¸üÐÂͬһ±íÖиÃÐÐÖ®ÍâµÄÊý¾Ý¡£
¡¡¡¡Ðм¶ËøÊÇÒ»ÖÖÅÅËûËø£¬·ÀÖ¹ÆäËûÊÂÎñÐ޸ĴËÐУ¬µ«ÊDz»»á×èÖ¹¶ÁÈ¡´ËÐеIJÙ×÷
¡£
¡¡¡¡ÔÚʹÓÃINSERT¡¢UPDATE¡¢DELETE ºÍSELECT…FOR UPDATE µÈÓï¾äʱ£¬Oracle
»á×Ô¶¯Ó¦ÓÃÐм¶ËøËø¶¨¡£SELECT...FOR UPDATE
Óï¾äÔÊÐíÓû§Ã¿´ÎÑ¡Ôñ¶àÐмǼ½øÐиüУ¬ÕâЩ¼Ç¼»á±»Ëø¶¨£¬ÇÒÖ»ÄÜÓÉ·¢Æð²éѯµÄÓû§½øÐб༭¡£Ö»ÓÐÔڻعö»òÌá½»ÊÂÎñÖ®ºó£¬Ëø¶¨²Å»áÊÍ·Å£¬ÆäËûÓû§²Å¿ÉÒÔ±à
¼­ÕâЩ¼Ç¼¡£
¡¡¡¡SELECT...FOR UPDATE Óï¾äµÄÓï·¨ÈçÏ£º
¡¡¡¡SELECT ... FOR UPDATE [OF column_list][WAIT n|NOWAIT][SKIP LOCKED];
ÆäÖУº
¡¡¡¡OF ×Ó¾äÓÃÓÚÖ¸¶¨¼´½«¸üеÄÁУ¬¼´Ëø¶¨ÐÐÉϵÄÌض¨ÁС£
¡¡¡¡WAIT ×Ó¾äÖ¸¶¨µÈ´ýÆäËûÓû§ÊÍ·ÅËøµÄÃëÊý£¬·ÀÖ¹ÎÞÏÞÆڵĵȴý¡£
¡¡¡¡“ʹÓÃFOR UPDATE WAIT”×Ó¾äµÄÓŵãÈçÏ£º
¡¡¡¡£±·ÀÖ¹ÎÞÏÞÆڵصȴý±»Ëø¶¨µÄÐУ»
¡¡¡¡£²ÔÊÐíÓ¦ÓóÌÐòÖжÔËøµÄµÈ´ýʱ¼ä½øÐиü¶àµÄ¿ØÖÆ¡£
¡¡¡¡£³¶ÔÓÚ½»»¥Ê½Ó¦ÓóÌÐò·Ç³£ÓÐÓã¬ÒòΪÕâЩÓû§²»Äܵȴý²»È·¶¨
¡¡¡¡£´ ÈôʹÓÃÁËskip locked£¬Ôò¿ÉÒÔÔ½¹ýËø¶¨µÄÐУ¬²»»á±¨¸æÓÉwait n Òý·¢µÄ‘×ÊԴæ’Òì³£±¨¸æ
ʾÀý:
create table t(a varchar2(20),b varchar2(20));
insert into t values('1','1');
insert into t values('2','2');
insert into t values('3','3');
insert into t values('4','4');
ÏÖÔÚÖ´ÐÐÈçϲÙ×÷£º
ÔÚplsql developeÖдò¿ªÁ½¸ösql´°¿Ú£¬
ÔÚ1´°¿ÚÖÐÔËÐÐsql
select * from t where a='1' for update;
ÔÚ2´°¿ÚÖÐÔËÐÐsql1
1. select * from t where a='1'; ÕâÒ»µãÎÊÌâҲûÓУ¬ÒòΪÐм¶Ëø²»»áÓ°Ïì´¿´âµÄselectÓï¾ä
ÔÙÔËÐÐsql2
2. select * from t where a='1' for update; ÔòÕâÒ»¾äsqlÔÚÖ´ÐÐʱ£¬ÓÀÔ¶´¦Óڵȴý״̬£¬³ý·Ç´°¿Ú1ÖÐsql±»Ìá½»»ò»Ø¹ö¡£
ÈçºÎ²ÅÄÜÈÃsql2²»µÈ´ý»òµÈ´ýÖ¸¶¨µÄʱ¼äÄØ£¿ ÎÒÃÇÔÙÔËÐÐsql3
3. select * from t where a='1' for update nowait; ÔòÔÚÖ´ÐдËsqlʱ£¬Ö±½Ó±¨×ÊԴæµÄÒì³£¡£
ÈôÖ´ÐÐ select * from t where a='1' for update wait 6; ÔòÔڵȴý6Ãëºó£¬±¨ ×ÊԴæµÄÒì³£¡£
Èç¹ûÎÒÃÇÖ´ÐÐsql4
4. select * from t where a='1' for update nowait skip Locked; ÔòÖ´ÐÐsqlʱ£¬¼´²»µÈ´ý£¬Ò²²»±¨×ÊԴæÒì³£¡£
ÏÖÔÚÎÒÃÇ¿´¿´Ö´ÐÐÈçϲÙ×÷½«»á·¢ÉúʲôÄØ£¿


Ïà¹ØÎĵµ£º

oracle µÄÍêȫжÔØ

1¡¢Windows 2000+ORACLE 8.1.7
2¡¢ORACLE°²×°Â·¾¶Îª£ºC:\\ORACLE
ʵÏÖ·½·¨£º
1¡¢        ¿ªÊ¼£­£¾ÉèÖã­£¾¿ØÖÆÃæ°å£­£¾¹ÜÀí¹¤¾ß£­£¾·þÎñ
        Í£Ö¹ËùÓÐOracle·þÎñ¡£
2¡¢        ¿ªÊ¼£­£¾³ÌÐò£­£¾Oracle - OraHome81£­£ ......

Oracle×Ö·û¼¯²âÊÔ

ÒÔÏ»شðÊôÓÚתÔØ£º
¾­³£¿´µ½Ò»Ð©ÅóÓÑÎÊORACLE×Ö·û¼¯·½ÃæµÄÎÊÌ⣬ÎÒÏëÒÔµü´úµÄ·½Ê½À´½éÉÜһϡ£
µÚÒ»´Îµü´ú£ºÕÆÎÕ×Ö·û¼¯·½ÃæµÄ»ù±¾¸ÅÄî¡£
ÓÐЩÅóÓÑ¿ÉÄÜ»áÈÏΪÕâÊǶà´ËÒ»¾Ù£¬µ«Êµ¼ÊÉÏÕýÊÇÓÉÓÚ¶ÔÏà¹Ø»ù±¾¸ÅÄî°ÑÎÕ²»Ç壬²Åµ¼ÖÂÁËÖî¶àÎÊÌâºÍÒÉÎÊ¡£
Ê×ÏÈÊÇ×Ö·û¼¯µÄ¸ÅÄî¡£
ÎÒÃÇÖªµÀ£¬µç×Ó¼ÆËã»ú×î³õÊÇÓÃÀ´½øÐпÆѧ¼ÆËãµÄ£¨Ë ......

Oracle³£¼û´íÎó——ORA 00054

ÈçºÎ½â¾öORA-00054×ÊÔ´Õý棬ҪÇóÖ¸¶¨NOWAIT£¿
 ²éÔÄ´íÎó´úÂëÖ¸ÄϺóÓÐÈçÏÂÌáʾ£º
ORA-00054 resource busy and acquire with NOWAIT specified
Cause: The NOWAIT keyword forced a return to the command prompt because a resource was unavailable for a LOCK TABLE or SELECT FOR UPDATE command.
Action: Tr ......

OracleÖÐÀûÓÃÒ»ÌõSQLÉú³É10ÍòÌõ¼Ç¼

  ×öÊý¾Ý¿â¿ª·¢»ò¹ÜÀíµÄÈ˾­³£Òª´´½¨´óÁ¿µÄ²âÊÔÊý¾Ý£¬¶¯²»¶¯¾ÍÐèÒªÉÏÍòÌõ£¬Èç¹ûÒ»ÌõÒ»ÌõµÄ¼È룬ÄÇ»áÀË·Ñ´óÁ¿µÄʱ¼ä£¬±¾ÎĽéÉÜÁËOracleÖÐÈçºÎͨ¹ýÒ»ÌõSQL¿ìËÙÉú³É´óÁ¿µÄ²âÊÔÊý¾ÝµÄ·½·¨¡£
²úÉú²âÊÔÊý¾ÝµÄSQLÈçÏ£º
SQL> select rownum as id,
  2         &nb ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ