Oracle更新多行

来源:互联网 发布:崩坏学园官方淘宝 编辑:程序博客网 时间:2024/04/28 06:40

更新多行的步骤:

步骤多,但效率比较高:
1、create table 临时表 value (select a.id,a.name,b.name,... from table1 a,table2 b where a.id=b.id)
2、删除table1中的记录,不要drop
3、insert into table1 select 你需要的字段 from 临时表。

 

 

select * from tb_ai03

create table tb_ai031 as select * from tb_ai03

delete  from tb_ai03 a where a.yymm in ('200911','200910')

insert into tb_ai03
select a.model,a.yysal/b.unitestrip as yysal ,a.mmsal/b.unitestrip as mmsal,
a.yychu/b.unitestrip as yychu,a.mmchu/b.unitestrip as mmchu,a.yymm
from tb_ld04 b,tb_ai031 a
where a.model=b.model(+) and a.yymm in ('200911','200910')

原创粉丝点击