Oracle dead lock deep research.
Update SQLS will lead dead lock exception. Because by default, it use optimistic lock but not pessimistic lock.
Below description is exceprted from the attachment(It exceeds my image that this blog can not upload the attachment,hehe)
Optimistic locking offers an elegant solution to the problems outlined above. Optimistic locking does
not lock records when they are read, and proceeds on the assumption that the data being updated has not
changed since the read. Since no locks are taken out during the read, it doesn’t matter if the user goes to
lunch after starting a transaction, and deadlocks are all but eliminated since users should never have to
wait on each other’s locks
There are some ways to resolve this problem.
1. Create a pessimistic lock. Change the sql like below formal.
First: select … from … for update nowait
Second: update the resultSet.
2. Execute the SQL again after a random duration when program meets this kind of exception. (It will consume lot of db server resource. I don't think it is the better way)
3. Schedule the SQL executed sequenced or split data without interfere.
Ïà¹ØÎĵµ£º
ÌìÓв»²â·çÔÆ£¬
IBM µÄÖж˴ÅÅÌÕóÁÐÕâ´ÎÓÖÈÇ»öÁË¡£ÔÚ΢ÂëÉý¼¶µÄʱºò£¬
DS4800 ·¢Éú¹ÊÕÏ¡£µ¼Öµ±Ê±ÔÚÕą̂¿âÉϵļ¸Ì×Éú²ú¿â±¨´íÁË¡£
IBM¹¤³Ìʦ°ÑÕóÁйÊÕϻָ´ºó£¬ÅÄÅÄÆ¨¹É×ßÈË£¬ÕóÁÐÉϵÄÊý¾ÝÓÖµÃÎÒÃÇÀ´Ïë°ì·¨ÇÀ¾ÈÁË¡£¡£¡£¡£
»¹ºÃÓÐoracle supportµÄÖ§³ÖÎÒÃÇ×îÖÕ»¯½âÁËÕâ´ÎΣ»ú¡£ÏÂÎÄÏêϸ½éÉÜÁËÕû¸ö»Ö¸´µÄ¹ý³Ì¡£
oracle¹¤ ......
¡¾ÑµÁ·6.1¡¿¡¡Ê¹ÓÃÒþʽÓαêµÄÊôÐÔ£¬Åж϶ԹÍÔ±¹¤×ʵÄÐÞ¸ÄÊÇ·ñ³É¹¦¡£
²½Öè1£ºÊäÈëºÍÔËÐÐÒÔϳÌÐò£º
BEGIN
UPDATE emp SET sal=sal+100 WHERE empno=1234;
IF SQL%FOUND THEN
DBMS_OUTPUT.PUT_LINE('³É¹¦Ð޸ĹÍÔ±¹¤×Ê£¡');
......
oracle grant
ÊÚȨÓï¾ä--select * from dba_users; ²éѯÊý¾Ý¿âÖеÄËùÓÐÓû§
--alter user TEST_SELECT account lock; Ëø×¡Óû§
--alter user TEST_SELECT account unlock; ¸øÓû§½âËø
--create user xujin identified by xujin; ½¨Á¢Óû§
--grant create tablespace to xujin; ÊÚȨ
--grant select ......
³£¼ûºǫ́½ø³Ì°üÀ¨:
• Êý¾Ý¿âд½ø³Ì (DBWn):½«Êý¾Ý¿â»º³åÇø¸ßËÙ»º´æÖеľ¹ýÐ޸ĵĻº³åÇø(»ÒÊý¾Ý»º ³åÇø)ÒÔÒì²½·½Ê½Ð´Èë´ÅÅÌ
• ÈÕ־д½ø³Ì (LGWR):½«ÈÕÖ¾»º³åÇøÖгÆÎªÖØ×öÐÅÏ¢µÄ»Ö¸´ÐÅϢдÈë´ÅÅÌÉϵÄÖØ×öÈÕ Ö¾Îļþ
• ¼ì²éµã½ø³Ì (CKPT):ÔÚ¿ØÖÆÎļþºÍÿ¸öÊý¾ÝÎļþÍ·ÖмǼ¼ì²éµãÐÅÏ¢
• ϵͳ¼àÊÓÆ÷½ø³ ......
[root@GISDB ~]$ su - oracle
[oracle@GISDB ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.4.0 - Production on Tue Oct 13 11:03:03 2009
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
To ......