oracle更新多个表,ORACLE的UPDATE更新多表
关于ORACLE的UPDATE更新多表的问题有以下几种方式可以实现:一种是:update table1set (field1,field2...) =(Select Field1,field2....from table2where table1.field1=table2.field1)where table1.field1 in (select field1 from table2)二种是:将
关于ORACLE的UPDATE更新多表的问题
有以下几种方式可以实现:
一种是:
update table1
set (field1,field2...) =
(Select Field1,field2....
from table2
where table1.field1=table2.field1)
where table1.field1 in (select field1 from table2)
二种是:
将table1,table2相关联字段建立主键Primary key 或Union key
Update (Select Table1.field1,table1.field2,table2.field1,table2.field2
from table1,table2
where Table1.Field1=table2.field1)
Set table1.table2=table2.table2,
table1.fieldn=table2.tablen,
......
table1的Field1和table2的field1将需要建立主键或唯一索引才行
三种是:
merge into table1
using table2
on (table1.field1=table2.field1 and ....)
when matched then Update set table1.field2=table2.field2,
table1.fieldn=table2.fieldn,
......
when not matched then [doing other thing]
其余方法可使用游标
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/cgboy88/archive/2009/12/30/5105594.aspx
关于ORACLE的UPDATE更新多表的问题有以下几种方式可以实现: 一种是: update table1 set (field1,field2...) = (Select Field1,field2.... from table2 where table1.field1=table2.field1) where table1.field1 in (select field1 from table2) 二种是: 将table1,table2相关联字段建立主键Primary key 或Union key Update (Select Table1.field1,table1.field2,table2.field1,table2.field2 from table1,table2 where Table1.Field1=table2.field1) Set table1.table2=table2.table2, table1.fieldn=table2.tablen, ...... table1的Field1和table2的field1将需要建立主键或唯一索引才行 三种是: merge into table1 using table2 on (table1.field1=table2.field1 and ....) when matched then Update set table1.field2=table2.field2, table1.fieldn=table2.fieldn, ...... when not matched then [doing other thing] 其余方法可使用游标 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/cgboy88/archive/2009/12/30/5105594.aspx
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐

所有评论(0)