oracle中for循环的问题
我要做循环查询出月份不同的表的数据放到新创建的表中...比如createdabing_1001asselect*frommacc.xhy_all_sum_200901cr...
我要做循环查询出月份不同的表的数据 放到新创建的表中...
比如
create dabing_1001 as
select * from macc.xhy_all_sum_200901
create dabing_1002 as
select * from macc.xhy_all_sum_200902
。。。。。。。。。。。。。。依次类推 以下是思路 请大家帮帮忙
declare
dabing varchar2(100);
dabing2 varchar2(100);
i number;
begin
for i in 1..8 loop
loop
dabing:='macc.xhy_all_sum_20090'||i;
dabing2:='dabing_100'+i;
create table dabing2 as
select * from dabing
end loop;
end; 展开
比如
create dabing_1001 as
select * from macc.xhy_all_sum_200901
create dabing_1002 as
select * from macc.xhy_all_sum_200902
。。。。。。。。。。。。。。依次类推 以下是思路 请大家帮帮忙
declare
dabing varchar2(100);
dabing2 varchar2(100);
i number;
begin
for i in 1..8 loop
loop
dabing:='macc.xhy_all_sum_20090'||i;
dabing2:='dabing_100'+i;
create table dabing2 as
select * from dabing
end loop;
end; 展开
展开全部
declare
dabing varchar2(100);
dabing2 varchar2(100);
ls_sql Varchar2(4000)
i number;
begin
for i in 1..8 loop
dabing:='macc.xhy_all_sum_20090'||i;
dabing2:='dabing_100'||i;
ls_sql:='Create table '||dabing2||' As select * from '||dabing;
Execute Immediate ls_sql;
end loop;
end;
以上,希望对你有所帮助!
dabing varchar2(100);
dabing2 varchar2(100);
ls_sql Varchar2(4000)
i number;
begin
for i in 1..8 loop
dabing:='macc.xhy_all_sum_20090'||i;
dabing2:='dabing_100'||i;
ls_sql:='Create table '||dabing2||' As select * from '||dabing;
Execute Immediate ls_sql;
end loop;
end;
以上,希望对你有所帮助!
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询