我想批量更新表中的数据,,,应为表中有几千万的数据,,,请问下面SQL语句有问题吗?
还有比这个更快的SQL语句吗? update
(
select
a.exam_result_id A1,
c.exam_result_id B1
from
the_d_exam_result_item a
join the_d_exam_result_frame b on a.exam_result_item_id = b.exam_result_item_id
join the_d_exam_result c on b.exam_result_frame_id = c.exam_result_frame_id
)
set A1 = B1时间常了报 ORA01089 错误,, 不知道是我SQL原因还是别人重启数据库了比如我这个SQL语句执行了1个小时,后来报错,那这1个小时有数据被更新吗???????????
还有比这个更快的SQL语句吗? update
(
select
a.exam_result_id A1,
c.exam_result_id B1
from
the_d_exam_result_item a
join the_d_exam_result_frame b on a.exam_result_item_id = b.exam_result_item_id
join the_d_exam_result c on b.exam_result_frame_id = c.exam_result_frame_id
)
set A1 = B1时间常了报 ORA01089 错误,, 不知道是我SQL原因还是别人重启数据库了比如我这个SQL语句执行了1个小时,后来报错,那这1个小时有数据被更新吗???????????
数据库起来之后你再执行一次呗。
--你的寫法更新出錯了,是不會更新到數據庫的
--幫你改了點,試下
create or replace procedure proc_t
is
begin
update
(
select
a.exam_result_id A1,
c.exam_result_id B1
from
the_d_exam_result_item a
join the_d_exam_result_frame b on a.exam_result_item_id = b.exam_result_item_id
join the_d_exam_result c on b.exam_result_frame_id = c.exam_result_frame_id
where a.exam_result_id<>c.exam_result_id and rownum<10000--每次更新多少自已指定
)
set A1 = B1;
commit;
end;
/
--執行更新
declare
v_i int := 0;
begin
loop
exit when v_i>10;--更新多少次自已指定吧
proc_t;
v_i := v_i+1;
end loop;
end;
/