1 Build partition Table
--Create TABLE
CREATE TABLE partition_table
(
field1 INTEGER,
field2 VARCHAR2),
Field3 INTEGER,
)
partition by Range (field3)
interval (86400)
(partition P1 values less than ( 1431964800)) nologging
tablespace user;
2 Adding stored procedures to the extended partition name
create OR REPLACE PROCEDURE pro_rename_partition as SQLSTR VARCHAR2 (4000);
Val2 int;
Newpart VARCHAR2 (32); BEGIN for REC in (select table_name to user_tables where table_name like ' partition_% ') loop for x in (select High_value, partition_name from User_tab_partitions where Table_ Name = REC.
TABLE_NAME and partition_name not like ' part_201% ') loop val2: = To_number (X.high_value);
Newpart: = ' Part_ ' | |
To_char (to_date (' 19700101080000 ', ' Yyyymmddhh24miss ') + (val2-3600)/86400,
' YYYYMMDD '); SQLSTR: = ' ALTER TABLE ' | | REC. table_name | |
' Rename partition ' | | X.partition_name | | ' To ' | |
Newpart;
Begin execute Immediate sqlstr;
Exception when others then null;
End
End Loop;
End Loop;
End Pro_rename_partition;
3 increasing the job-timed call to the stored procedure
/
begin
Dbms_scheduler.create_job
(
job_name => ' job_pro_rename_partition ',
job_type => ' Plsql_block ',
job_action => ' begin pro_rename_partition; end; ',
repeat_interval => ' freq=daily; Byhour=1;byminute=0 ',
enabled => true
);
End;
/