create or replace procedure p_insert is
v_num number :=18888880000;
v_time date :=sysdate;
begin
while v_num<18888885001 loop
insert into BASE_LATESTPOSITION (id,TIME) values(v_num,v_time);
v_num :=v_num+1;
v_time :=v_time+1/1440;
end loop;
commit;
end;
create or replace procedure p_insertbase(p_phonenumber in int) is
v_num int default '0';
v_num2 int default '0';
--v_time date :=sysdate;
v_code int;
v_tablename varchar2(30);
v_sql varchar2(4000);
begin
v_tablename := TRIM('T_BASE' || p_phonenumber);
select count(*)
into v_num
from base_latestposition
where id = p_phonenumber;
if v_num = 0 then
select count(*)
into v_num2
from user_tables t
where t.table_name = v_tablename;
if v_num2 = 0 then
v_sql := 'CREATE TABLE ' || ' ' || v_tablename || '(
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''))
)';
execute immediate v_sql;
end if;
end if;
exception
when others then
rollback;
dbms_output.put_line(SQLCODE || SQLERRM);
end p_insertbase;
create or replace procedure p_insert_2 is
v_num number :=18888880001;
--v_time date :=sysdate;
v_code int;
begin
while v_num<18888885001 loop
select floor(dbms_random.value(300,5000)) into v_code from dual ;
insert into base_terminalinfo (id,code,sim,protocolid) values(v_num,v_code,v_num,'34');
v_num :=v_num+1;
end loop;
commit;
end;