sql优化问题,想把红色部分删了,请帮我看看删了和不删结果是不是一样,这个sql数据量有可能达到1百万,对oracle优化不熟,各位解答一下,谢谢
declare
begin
for i in (select a.no
from detail a
where a.submit_date between date '2012-6-1' and date
'2012-12-31'
and a.code in
(select dr.child_code
from code_relation dr
where dr.parent_code = '288'
union
select t.specail_code
from specail_general_relation t
where t.general_code in
(select dr.child_code
from code_relation dr
where dr.parent_code = '288'))) loop
update detail a
set a.amount = (select max(b.amount) --日常展业费
from OTHER_DETAIL b
where a.no = b.no
and b.other_no is null)
where a.submit_date between date '2012-6-1' and date
'2012-12-31'
and
and a.code in (select dr.child_code
from code_relation dr
where dr.parent_code = '288'
union
select t.specail_code
from specail_general_relation t
where t.general_code in
(select dr.child_code
from code_relation dr
where dr.parent_code = '288')) and a.no = i.no
and exists (select 1
from OTHER__DETAIL b
where a.no = b.no
and b.other_no is null);
end loop;
end;
优化sqloracle
declare
begin
for i in (select a.no
from detail a
where a.submit_date between date '2012-6-1' and date
'2012-12-31'
and a.code in
(select dr.child_code
from code_relation dr
where dr.parent_code = '288'
union
select t.specail_code
from specail_general_relation t
where t.general_code in
(select dr.child_code
from code_relation dr
where dr.parent_code = '288'))) loop
update detail a
set a.amount = (select max(b.amount) --日常展业费
from OTHER_DETAIL b
where a.no = b.no
and b.other_no is null)
where a.submit_date between date '2012-6-1' and date
'2012-12-31'
and
and a.code in (select dr.child_code
from code_relation dr
where dr.parent_code = '288'
union
select t.specail_code
from specail_general_relation t
where t.general_code in
(select dr.child_code
from code_relation dr
where dr.parent_code = '288')) and a.no = i.no
and exists (select 1
from OTHER__DETAIL b
where a.no = b.no
and b.other_no is null);
end loop;
end;
优化sqloracle
解决方案 »
- 高手帮忙看一下,PROCEDURE 不能编译 ,急!在线等
- 三个表的关系查询和统计。有点急,请大家帮帮忙。谢谢!
- insert语句的问题:插入重复数据时语句的书写。
- 关于用sqlplus调用存储过程,救救小妹我吧
- 如何从\4E2D\56FD\4EBA\6C11得到"中国人民"?
- 新人求助,linux中oracle启动失败!
- 一个oracle9i触发器问题,请高手帮忙!急,高分悬赏!
- 请给我以指导
- ORACLE到底哪方面比MSSQL SERVER好,为什么一说到大型数据库就总要用ORACLE。
- 紧急求助(高手请进!有高分!!!)在asp中连接oracle出错问题!
- oracle锁表ora-00030:User session ID does not exist.如何解决?
- 并发交换2行数据 事务和锁的关系 求解
begin
for i in (select a.no
from detail a
where a.submit_date between date '2012-6-1' and date
'2012-12-31'
and a.code in
(select dr.child_code
from code_relation dr
where dr.parent_code = '288'
union
select t.specail_code
from specail_general_relation t
where t.general_code in
(select dr.child_code
from code_relation dr
where dr.parent_code = '288'))) loop
update detail a
set a.amount = (select max(b.amount) --日常展业费
from OTHER_DETAIL b
where a.no = b.no
and b.other_no is null)
where a.submit_date between date '2012-6-1' and date
'2012-12-31'
and a.no=i.no
and a.code in (select dr.child_code
from code_relation dr
where dr.parent_code = '288'
union
select t.specail_code
from specail_general_relation t
where t.general_code in
(select dr.child_code
from code_relation dr
where dr.parent_code = '288')) and a.no = i.no
and exists (select 1
from OTHER__DETAIL b
where a.no = b.no
and b.other_no is null);
end loop;
end;
declare
begin
for i in (select a.no
from detail a
where a.submit_date between date '2012-6-1' and date
'2012-12-31'
and a.code in
(select dr.child_code
from code_relation dr
where dr.parent_code = '2'
union
select t.specail_code
from specail_general_relation t
where t.general_code in
(select dr.child_code
from code_relation dr
where dr.parent_code = '2'))) loop
update detail a
set a.amount = (select max(b.amount) --日常展业费
from OTHER_DETAIL b
where a.no = b.no
and b.other_no is null)
where a.submit_date between date '2012-6-1' and date
'2012-12-31'
and a.no=i.no
and a.code in (select dr.child_code
from code_relation dr
where dr.parent_code = '288'
union
select t.specail_code
from specail_general_relation t
where t.general_code in
(select dr.child_code
from code_relation dr
where dr.parent_code = '288')) and a.no = i.no
and exists (select 1
from OTHER__DETAIL b
where a.no = b.no
and b.other_no is null);
end loop;
end;