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

oracle PL/SQL FOR UPDATE Óë FOR UPDATE OFµÄÇø±ð

PL/SQL-FOR UPDATE Óë FOR UPDATE OFµÄÇø±ð
url:http://hi.baidu.com/1413/blog/item/a521251f7e5993c4a686696b.html
Êý¾Ý¿â oracle for update of   ºÍ   for updateÇø±ð    
select * from TTable1 for update Ëø¶¨±íµÄËùÓÐÐУ¬Ö»ÄܶÁ²»ÄÜд
2 select * from TTable1 where pkid = 1 for update Ö»Ëø¶¨pkid=1µÄÐÐ
3 select * from Table1 a join Table2 b on a.pkid=b.pkid for update Ëø¶¨Á½¸ö±íµÄËùÓмǼ
4 select * from Table1 a join Table2 b on a.pkid=b.pkid where a.pkid = 10 for update Ëø¶¨Á½¸ö±íµÄÖÐÂú×ãÌõ¼þµÄÐÐ
5. select * from Table1 a join Table2 b on a.pkid=b.pkid where a.pkid = 10 for update of a.pkid Ö»Ëø¶¨Table1ÖÐÂú×ãÌõ¼þµÄÐÐ
for update ÊÇ°ÑËùÓÐµÄ±í¶¼Ëøµã for update of ¸ù¾Ýof ºó±íµÄÌõ¼þËø¶¨Ïà¶ÔÓ¦µÄ±í
-----------
¹ØÓÚNOWAIT(Èç¹ûÒ»¶¨ÒªÓÃFOR UPDATE£¬ÎÒ¸ü½¨Òé¼ÓÉÏNOWAIT)
µ±ÓÐLOCK³åͻʱ»áÌáʾ´íÎó²¢½áÊøSTATEMENT¶ø²»ÊÇÔÚÄÇÀïµÈ´ý(±ÈÈç:Òª²éµÄÐÐÒѾ­±»ÆäËüÊÂÎñËøÁË,µ±Ç°µÄËøÊÂÎñÓëÖ®³åÍ»,¼ÓÉÏnowait,µ±Ç°µÄÊÂÎñ»á½áÊø»áÌáʾ´íÎó²¢Á¢¼´½áÊø STATEMENT¶ø²»Ôٵȴý).
Èç¹û¼ÓÁËfor updateºó ¸ÃÓï¾äÓÃÀ´Ëø¶¨Ìض¨µÄÐУ¨Èç¹ûÓÐwhere×Ӿ䣬¾ÍÊÇÂú×ãwhereÌõ¼þµÄÄÇЩÐУ©¡£µ±ÕâЩÐб»Ëø¶¨ºó£¬ÆäËû»á»°¿ÉÒÔÑ¡ÔñÕâЩÐУ¬µ«²»Äܸü¸Ä»òɾ³ýÕâЩÐУ¬Ö±µ½¸ÃÓï¾äµÄÊÂÎñ±»commitÓï¾ä»òrollbackÓï¾ä½áÊøΪֹ¡£
ÒòΪFOR   UPDATE×Ó¾ä»ñµÃÁËËø£¬ËùÒÔCOMMIT½«ÊÍ·ÅÕâЩËø¡£µ±ËøÊÍ·ÅÁË£¬¸ÃÓαê¾ÍÎÞЧÁË¡£


Ïà¹ØÎĵµ£º

SQL DateTime²éѯÓë¸ñʽ

select * from orders where month(orderdate)= (select month(orderdate) from orders where orderid=10248)
1.Ò»¸öÔµÚÒ»ÌìµÄ
Select DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)
2.±¾ÖܵÄÐÇÆÚÒ»
Select DATEADD(wk, DATEDIFF(wk,0,getdate()), 0)
3.Ò»ÄêµÄµÚÒ»Ìì
Select DATEADD(yy, DATEDIFF(yy,0,getdate()), 0) ......

SQL´æ´¢¹ý³ÌʵÀý


Àý1 ´«ÈëÒ»¸ö²ÎÊý@username,ÅжÏÓû§ÊÇ·ñ´æÔÚ
-------------------------------------------------------------------------------
CREATE PROC IsExistUser
(
@username varchar(20),
@IsExistTheUser varchar(25) OUTPUT--Êä³ö²ÎÊý
)
as
SELECT @IsExistTheUser = count(username)
from users
WHERE username ......

sql´æ´¢¹ý³ÌѧϰʵÀý

ʲôÊÇ´æ´¢¹ý³ÌÄØ£¿
¡¡¡¡¶¨Ò壺
¡¡¡¡½«³£ÓõĻòºÜ¸´ÔӵŤ×÷£¬Ô¤ÏÈÓÃSQLÓï¾äдºÃ²¢ÓÃÒ»¸öÖ¸¶¨µÄÃû³Æ´æ´¢ÆðÀ´, ÄÇôÒÔºóÒª½ÐÊý¾Ý¿âÌṩÓëÒѶ¨ÒåºÃµÄ´æ´¢¹ý³ÌµÄ¹¦ÄÜÏàͬµÄ·þÎñʱ,Ö»Ðèµ÷ÓÃexecute,¼´¿É×Ô¶¯Íê³ÉÃüÁî¡£
¡¡¡¡½²µ½ÕâÀï,¿ÉÄÜÓÐÈËÒªÎÊ£ºÕâô˵´æ´¢¹ý³Ì¾ÍÊÇÒ»¶ÑSQLÓï¾ä¶øÒÑ°¡£¿
¡¡¡¡Microsoft¹«Ë¾ÎªÊ²Ã´»¹ÒªÌí¼ÓÕ ......

linq to sql Óï·¨ ѧϰ±Ê¼Ç ´æÒ»ÏÂ

Join²Ù×÷·û
ÊÊÓó¡¾°£ºÔÚÎÒÃDZí¹ØϵÖÐÓÐÒ»¶ÔÒ»¹Øϵ£¬Ò»¶Ô¶à¹Øϵ£¬¶à¶Ô¶à¹ØϵµÈ¡£¶Ô¸÷¸ö±íÖ®¼äµÄ¹Øϵ£¬¾ÍÓÃÕâЩʵÏÖ¶Ô¶à¸ö±íµÄ²Ù×÷¡£
˵Ã÷£ºÔÚJoin²Ù×÷ÖУ¬·Ö±ðΪJoin(Join²éѯ), SelectMany(SelectÒ»¶Ô¶àÑ¡Ôñ)ºÍGroupJoin(·Ö×éJoin²éѯ)¡£
¸ÃÀ©Õ¹·½·¨¶ÔÁ½¸öÐòÁÐÖмüÆ¥ÅäµÄÔªËؽøÐÐinner join²Ù×÷
SelectMany
˵Ã÷£ºÎÒà ......

jdbcÖе÷ÓÃoracle ·µ»ØÓαêÀàÐ͵Ĵ洢¹ý³Ì

1¡¢´´½¨±í£º
     create table stud(
            sid int,
            sname varchar2(50)
     )
     ²¢²åÈëÒ»ÌõÊý¾Ý
 &n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ