Oracle¶à±íÁ¬½Ó¸üÐÂ
Á½¸ö±íA,Bͨ¹ý×Ö¶ÎID INNER JOINÁ¬½Ó£¬ÏÖÏë¸üбíBÖеÄQTYֵΪ±íAµÄQTYÖµ£¬µ«Ö»¸üÐÂÕâÁ½¸öQTY²»Ò»ÑùµÄ²¿·Ö£¬Ò»ÑùµÄ²»¶¯¡£
ÔÎ, Ò»ÑùµÄ¶¯²»¶¯ÓÐÊ²Ã´Çø±ðÂð?
·½Ê½1, update
update a
set a.qty = (select qty from b where a.id = b.id)
where exists (select 1 from b where a.id = b.id and a.qty <> b.qty)
·½Ê½2, merge into
merge into a
using (select b.* from a, b where a.id = b.id and a.qty <> b.qty ) b
on (a.id = b.id)
when matched then
update set a.qty = b.qty
when not matched then
insert (a.id,a.qty)
values(b.id,b.qty)
ÒòΪÊý¾ÝÁ¿Ì«´ó£¬ËäÈ»Ã»Çø±ð£¬µ«ÕâÑù²»ÊǵÈÓÚÕû¸ö±í¸üÐÂÁËÂð£¿
SQL code:
merge into B
using A
on(B.id = a.id)
when matched then
update set B.QTY=A.QTY where B.QTY<>A.QTY;
SQL code:
update a
set a.qty = (select qty from b where a.id = b.id)
where exists (select 1 from b where a.id = b.id and a.qty <> b.qty)
2Â¥ 4Â¥Äĸö¶Ô£¿
¶¼¿ÉÒÔ¡£Ò»¸öÊÇûÓÐÕÒµ½µÄÇé¿öϾÍΪinsertÒ»Ìõ½¨Òé2Â¥
2Â¥ºÜ¶Ô°¡
merge into B
using A
on(B.id = a.id)
when matched then
update set B.QTY=A.QTY where
Ïà¹ØÎÊ´ð£º
abnormal end of export file
IMP-00028: partial import of previous table rolled back: 3828 rows rolled back
ÓÐûÓÐÒ»ÖÖ·½·¨Èõ¼Èë¼ÌÐø½øÐжø²»Òì³£Ìø³ö»Ø¹ö£¿
ignore=y
Äã² ......
¸÷λoracle¸ßÊÖ£¬Çë½ÌÒ»ÏÂΪʲôoracle 10gÔÚ°²×°µ½°Ù·ÖÖ®°ËÊ®ÎåµÄʱºò¾Í±¨´í²»ÄܼÌÐø°²×°£¿
ÄÚ´æ¶à´ó£¿¡¡ÖØÐÂϸöÊý¾Ý¿â°²×°ÊÔÊÔ..
ÒýÓÃ
¸÷λoracle¸ßÊÖ£¬Çë½ÌÒ»ÏÂΪʲôoracle 10gÔÚ°²×°µ½°Ù·ÖÖ®°ËÊ®ÎåµÄʱ ......
private static final String URL = "jdbc:oracle:thin:@localhost:1521:orcl";
private static final String USERNAME = "sys";
private static final String PASSWORD = "s ......
ÈçÏÂ2ÕÅ±í£º
table1:
node_id
parent_id
root_id
value
table2:
node_id
status
±í1´æ´¢ÁËÒ»¿ÃÊ÷£¬±í2´æ´¢Á˽ڵã״̬£¬ÎÊÌâÈçÏ£º
ÈçºÎÓÃSQLÓï¾ä»ñµÃ״̬statusΪ1µÄ½ÚµãµÄËùÓÐ×Ó½ÚµãÒÔ¼°ÆäÏÂ×ÓÊ÷ÖÐËùÓÐ½Ú ......
ÔÚϵͳÔËÐеÄʱºò×ÜÊÇÓÐÒ»¿é´ÅÅÌʼÖÕÉÁºìµÆ£¬½øÈëϵͳºó
#topas²é¿´×ÜÊÇÓÐÒ»¿é´ÅÅÌ%BUSYΪ90%ÒÔÉÏ£¬
Êý¾Ý¿â°æ±¾£ºoracle 9.2.0.7
Êý¾ÝÎļþ¹ÒÔØµÄ½Úµã£º/oradata/pcs/ Âß¼¾íºÅlv04
#lslv -l lv04
......