日期:2014-05-16 浏览次数:20954 次
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;