create or replace procedure create_table
as p_s varchar2(4000);
begin
for i in 1..500 loop
p_s:='CREATE TABLE '||'BASE_T1888888'||LTRIM(TO_CHAR(i,'0099'))||
'(
time DATE primary key,
warningflag NUMBER(10) not null,
status NUMBER(10) not null,
lon NUMBER(10) not null,
lat NUMBER(10) not null,
velocity NUMBER(11) not null,
direction NUMBER(11) not null,
dem NUMBER(10) not null,
servertime DATE not null,
address VARCHAR2(256) not null,
i0 NUMBER(11) not null,
i1 NUMBER(11) not null,
i2 NUMBER(11) not null,
i3 NUMBER(11) not null,
i4 NUMBER(11) not null,
i5 NUMBER(11) not null,
i6 NUMBER(11) not null,
i7 NUMBER(11) not null,
i8 NUMBER(11) not null,
i9 NUMBER(11) not null,
i10 NUMBER(11) not null,
i11 NUMBER(11) not null,
i12 NUMBER(11) not null,
i13 NUMBER(11) not null,
i14 NUMBER(11) not null,
d0 NUMBER(15,10) not null,
d1 NUMBER(15,10) not null,
d2 NUMBER(15,10) not null,
d3 NUMBER(15,10) not null,
d4 NUMBER(15,10) not null,
s0 VARCHAR2(128),
s1 VARCHAR2(128),
s2 VARCHAR2(128),
s3 VARCHAR2(128),
s4 VARCHAR2(128),
additional NUMBER(10) not null
)
partition by range (TIME)
interval (numtoyminterval(1,''month''))
(
partition P_FIRST values less than (TO_DATE(''2012-02-01 00:00:00'', ''SYYYY-MM-DD HH24:MI:SS'', ''NLS_CALENDAR=GREGORIAN''))
)';--创建表的sql语句
DBMS_OUTPUT.put_LINE(i);
execute immediate p_s;--创建表
-- insert into test_sql values (p_s);
-- commit;
end loop;
exception
when others then
dbms_output.put_line(SQLCODE || SQLERRM);
end;
转载于:https://my.oschina.net/dongmenfeishu/blog/215090