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

oracle Ìæ»»Êý¾ÝµÄsql¸ÃÔõôд - Oracle / ¿ª·¢

ÓÐÁ½Õűí
  A B
  id hyid hyid newid
  1 2 2 A
  2 3 3 B
  ÏÖÔÚÒª½«a±íµÄhyid»»³Éb±íµÄnewid,Çë×¢Òâa±íÖеÄhyid²»ÊÇΨһµÄ
  oracleÖиà Ôõô´¦Àí


merge into a using b 
on (a.hyid=b.hyid)
when matched then
update set a.hyid=b.newid  
a.hyid ÔÚon¾äÖÐ,²»ÄÜÐÞ¸Ä

ÎÒÁíÍâÔÚa±íÖÐŪÁËÒ»ÌõÊý¾ÝhyºÍhyid±£³ÖÒ»ÖÂ
²¢ÇÒÒòΪa±íÖеÄhyid²»ÊÇΨһµÄ,½á¹û´íÎóÎÞ·¨»ñµÃÎȶ¨ÐÐ
update a set hyid=(
  select newid from b where hyid=a.hyid)
where exists(
  select 1 from b where hyid=a.hyid)

SQL code:
update a set a.hyid=(select newid from b where b.hyid=a.hyid and rownum<2)
and exists (select 1 from b where b.hyid=a.hyid);


ÒýÓÃ
update a set hyid=(
select newid from b where hyid=a.hyid)
where exists(
select 1 from b where hyid=a.hyid)


1Â¥Õý½â£¬ÓÃmergeÎÞ·¨ÐÞ¸Ä

¿´Ñù×Ó²»´í ,²»¹ý»¹ÊÇÐ޸IJ»ÁË,´íÎó:µ¥ÐÐ×Ó²éѯ·µ»Ø¶à¸öÐÐ
 

--where rownum=1ÏÞÖÆÏÂ

update a set hyid=(
select newid from b where hyid=a.hyid where rownum=1)
where exists(
select 1 from b w


Ïà¹ØÎÊ´ð£º

Çë½ÌsqlÓï¾ä¡£ - Oracle / ¿ª·¢

ÎÒÓÐÒ»¸ö±í£¬½á¹¹ÊÇÕâÑù¡£
  ת³ö µ¥Î» תÈ뵥λ ±ÊÊý ½ð¶î
date(Ö÷) outid(Ö÷) inid(Ö÷) num amt
2009 1 2 1 500 Ϊ 1 µ¥Î» ÔÚ2009Ä ......

sqlССµÄÒÉÎÊ - .NET¼¼Êõ / C#

¿ÉÄÜÒòΪ¹¤×÷µÄÔ­Òò ½Ó´¥Êý¾Ý¿âÕâ¿é±È½ÏÉÙ£¬Ö®Ç°¶¼ÊÇ×ö³ÌÐòÕâ¿é£¬Êý¾Ý¿âÕâ¿é¶¼ÓÐרÃŵÄÈËÀ´×ö ·Ö¹¤¶¼ºÜÃ÷ϸ ËùÒÔ¶ÔÊý¾Ý¿âÕâÒ»¿éÍêÈ«²»Á˽⡣ǰ¶Îʱ¼ä È¥ÃæÊÔÁ˼¸¼Ò¹«Ë¾ ¼¸ºõ¶¼ÊÇÔÚÊý¾Ý¿âÕâ¿é¹ÒµôµÄ Á¬¸ö¼òµ¥µÄSQ ......

oracle³õѧÕßÄãÇë½Ì - Oracle / »ù´¡ºÍ¹ÜÀí

--½¨Á¢Ò»¸ö°üÒÔ¶¨ÒåÒ»¸öÓαê
create or replace package PK_test 
as 
type cur_test is ref cursor;
end PK_test;
--½¨Á¢Ò»¸ö¹ý³Ì,ͨ¹ýÊäÈëJOBID£¬·µ»ØÒ»¸ö±í¼Ç¼£¨Óα꣩!
create or replace ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ