3,491
社区成员
发帖
与我相关
我的任务
分享
--修改一下,忘记 rec.logdate 拼接后变成字符串了
--要修改为拼接后的结果为 to_date(rec.logdate,'xxxxxxx) 这样的
--修改如下
begin
for rec in(select distinct trunc(t,'dd') logdate from a)
loop
execute immediate 'create table A'|| to_char(rec.logdate,'yyyymmdd')
||' as select * from A where A.t >= '
||'to_date('''
|| to_char(rec.logdate,'yyyy-mm-dd')
||''',''yyyy-mm-dd'')'
||' and A.t < '
||' to_date('''
|| to_char(rec.logdate + 1,'yyyy-mm-dd')
||''',''yyyy-mm-dd'')'
|| ';';
end loop;
end;
begin
for rec in(select distinct trunc(t,'mm') logdate from a)
loop
execute immediate 'create table A'|| to_char(rec.logdate,'yyyymm')
||' as select * from A where A.t >= '
||'to_date('''
|| to_char(rec.logdate,'yyyy-mm')
||''',''yyyy-mm'')'
||' and A.t < '
||' to_date('''
|| to_char(add_months(rec.logdate,1),'yyyy-mm')
||''',''yyyy-mm'')'
|| ';';
end loop;
end;
begin
for rec in(select distinct trunc(t,'dd') logdate from a)
loop
execute immediate 'create table A'|| to_char(rec.logdate,'yyyymmdd')
||' as select * from A where A.t >= '
|| rec.logdate
||' and A.t < '
|| rec.logdate + 1
|| ';';
end loop;
end;