Oracle creates a timestamp partitioned table ____oracle

Source: Internet
Author: User

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; 
/





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.