sql ²éѯ-¸üР×èÈû¡£¡£¡£¡££¿
Óöµ½µÄÏÖÏóÊÇ Í¬Ò»¸ö±íµÄquery»á×èÈûupdate
sql query ºÍupdate ²Ù×÷ query»á×èÈûupdate²Ù×÷Âð
Ôõô½â¾ö
ÊDz»ÊÇʲôÉèÖò»¶Ô»¹ÊÇÔõµÄ
Èç¹û»áµÄ»°£¬ÄÇͬһ¸ö±íµÄƵ·±query and update ÄÇÊý¾Ý¿â²»×èÈûµÄ²»ÏñÑù×Ó°¡
Çó½â
ѧϰ£¬°ï¶¥£¬×îºÃÃèÊöһϾßÌåÒµÎñ
SQL code:
1 ÈçºÎËøÒ»¸ö±íµÄijһÐÐ
A Á¬½ÓÖÐÖ´ÐÐ
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
begin tran
select * from tablename with (rowlock) where id=3
waitfor delay '00:00:05'
commit tran
BÁ¬½ÓÖÐÈç¹ûÖ´ÐÐ
update tablename set colname='10' where id=3 --ÔòÒªµÈ´ý5Ãë
update tablename set colname='10' where id<>3 --¿ÉÁ¢¼´Ö´ÐÐ
2 Ëø¶¨Êý¾Ý¿âµÄÒ»¸ö±í
SELECT * from table WITH (HOLDLOCK)
×¢Òâ: Ëø¶¨Êý¾Ý¿âµÄÒ»¸ö±íµÄÇø±ð
SELECT * from table WITH (HOLDLOCK)
ÆäËûÊÂÎñ¿ÉÒÔ¶ÁÈ¡±í£¬µ«²»ÄܸüÐÂɾ³ý
SELECT * from table WITH (TABLOCKX)
ÆäËûÊÂÎñ²»ÄܶÁÈ¡±í,¸üкÍɾ³ý
SQL code:
ÅÅËûËø
http://topic.csdn.net/u/20080425/10/a1d7d337-a918-4c8c-ba97-44ae4472ade4.html?1527885039
²»Ã÷°×ʲôÒâ˼
.
Èç¹ûÊÇËøµÄ»°¿ÉÒԲο¼Ï£º
http://blog.csdn.net/fredrickhu/archi
Ïà¹ØÎÊ´ð£º
ÓÐÁ½¸ö±í¡£·Ö±ð¶¼ÓÐIDÖ÷¼ü¡£A±íµÄIDºÍB±íµÄIDÊǶÔÓ¦µÄ£¬¾ÍÊÇA±í¼¸¸öID£¬B±í¾Í¼¸¸öID¡£A±íµÄIDÊÇʲô,B±íµÄID¾ÍÊÇʲô¡£
¿ÉÊÇÏÖÔÚA±íµÄID±ÈB±íµÄ¶àÁË¡£
ÎÒÏÖÔÚÏëÒª°ÑB±íÖÐÉٵIJ¿·Ö¸ø²¹ÆëÁË¡£Õâ¸ö²åÈëÓ¦¸ÃÔõôд ......
linq to sqlÀïÔõÑùʹËüÔÚ²åÈëÊý¾Ýʱ×Ô¶¯½Ø¶Ï¹ý³¤µÄ×Ö·û´®¶ø²»ÊÇÅ׳ö´íÎó
¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£ÎÒͨ³£¶¼ÊÇÌύʱ¾Í¼ì²éËûÔÚ³¤¶È¡£¡£¡£
²»ÊÇ£¬ÏÖÔÚÊÇÏîÄ¿×öÍêÁË£¬ºÜ¶àÄ£¿é²åÈëÊý¾Ýʱ¶¼³öÏÖÕâÑùµÄÎÊÌâ¡£ÒÔÇ°ÓÃsqlpa ......
listidÊÇintÊý¾Ý
declare @listid nvarchar(100)
set @listid='(1,2,3,7,9,10)'
select * from forums where listid in(@listid)ʱÌáʾÈçÏ´íÎó£º
ÔÚ½« nvarchar Öµ '(1,2,3,7,9,10)' × ......
×ÜÊý±í
×ֶΠnum,freq
numÊÇËùÊôÆÚµÄ×ÜÊý£¬freqÊǼǼ¸ÃÊýÖµËùÊôÄÄÒ»ÆÚµÄ
ÇøÓò±í
×ֶΠarea_name,tot,freq
ÇøÓòÃû³Æ£¬¸ÃÇøÓòµÄ×ÜÊý£¬ËùÊôÆÚ
Á½ÕÅ±í¿¿freq¹ØÁª£¬ÇÒ²»ÊÇ×ÔÔö×ֶΣ¬²»ÊÇÖ ......
µã»÷¡°·þÎñ¹ÜÀíÆ÷¡±£¬µã»÷¡°¿ªÊ¼/¼ÌÐø¡±£¬×ÜÊÇÏÔʾ¡°ÓÉÓڵǼʧ°Ü¶øÆô¶¯·þÎñ¡±£¬È»ºóÔٴγö´í£¬²»Äܹ»½øÈ룬Ҳ²»Äܹ»²é¿´ÊôÐÔ£¬ÇëÎÊ´ó¼Ò¸ÃÔõô°ì£¿
ÎÒÊDzſªÊ¼Ñ§Ï°Êý¾Ý¿â£¬ÇëÎÊ´ó¼ÒÓÐûÓÐʲôºÃһЩµÄ½¨Òé»òÕ ......