当前位置:Gxlcms > 数据库问题 > DB2用一张表更新其他表的数据

DB2用一张表更新其他表的数据

时间:2021-07-01 10:21:17 帮助过:6人阅读

1. declare cursor t1 is select * from tablename; begin for rec in t1 loop update tablename t set t.detail=rec.jieshao where t.objectid=rec.objid; end loop; end;

2.

update   student   set   (name,id   )=     (select   name   ,id     from   (select   student.rowid   rd,student1.name,student1.id   from   student1,student   where   student1.int_id   =student.int_id)   tmp     where   student.rowid=tmp.rd);     commit;

3.

update test_a a set (a.name,a.age)= (select b.name,b.age from test_b b where a.id = b.id) where exists (select * from test_b c where c.id=a.id)

4.

UPDATE   t_A   SET   Djrq=       (             SELECT   djrq   FROM   t_B   WHERE   t_A.ID   =   T_B.ID               WHERE   ROWNUM   =   1       )     WHERE   t_A.ID   IN       (             SELECT   ID   FROM   t_B   WHERE   jwh=‘XX村‘     )

5.

update tbl1 a    set (a.col1, a.col2) = (select b.col1, b.col2                               from tbl2 b                               where a.key = b.key)    where a.key in(select key from tbl2)

DB2用一张表更新其他表的数据

标签:

人气教程排行