update t_a a
set a.a = (select a from t_b b where a.a = b.a )其中 t_a有1000万行, t_b有10万行,
这样写效率高吗?
如何效率更高?一个解决办法是把要更新的t_a表的记录先插入一张临时表,把源表记录删除,
然后在临时表中采用类似上面的语句更新,接着从临时表插入到源表。
有没有更好的?
set a.a = (select a from t_b b where a.a = b.a )其中 t_a有1000万行, t_b有10万行,
这样写效率高吗?
如何效率更高?一个解决办法是把要更新的t_a表的记录先插入一张临时表,把源表记录删除,
然后在临时表中采用类似上面的语句更新,接着从临时表插入到源表。
有没有更好的?
set a.a = (select a from t_b b where a.a = b.a )
你这句话好象没有什么意义 用了和没用一样
insert into a select * from temp_a; drop table temp_a;整个大概不到3分钟
跑过程会不会快一点?declare
v_oid number; 关键字
cursor cs is select a from t_b;
begin
for c1 in cs loop
select a into v_oid from t_b where a = c1.a;
update t_a set a = a? where a = v_oid;
commmit;
end loop;
end;
取出表1的关键字和要更新的值,
insert into a select * from temp_a; drop table temp_a;整个大概不到3分钟a是从表才成立