Oracle Partition Table instance

Source: Internet
Author: User

Example of Oracle Partition Table usage:

Create or replace procedure bl_partition is
V_ SQL varchar (1024 );
V_count int;
V_partname varchar2 (32 );
V_startdate date;
V_enddate date: = trunc (sysdate) + 1;
Begin
V_ SQL: = 'select count (*) from user_tables where table_name = ''bl _ test ''';
Execute immediate v_ SQL
Into v_count;
If v_count = 0 then
V_ SQL: = 'create table bl_test (period date, abcd varchar2 (20) nologging partition by range (period)
(Partition pmax values less than (MAXVALUE) tablespace bl_test )';
Execute immediate v_ SQL;
End if;
V_ SQL: = 'select max (partition_name) from user_tab_partitions where table_name = ''bl _ test'' and partition_name <> ''pmax ''';
Execute immediate v_ SQL
Into v_partname;
If v_partname is null then
V_startdate: = trunc (sysdate)-2;
Else
V_startdate: = to_date (substr (v_partname, 2), 'yyyymmdd ');
End if;
While v_startdate <v_enddate loop
V_startdate: = v_startdate + 1;
V_partname: = 'P' | to_char (v_startdate, 'yyyymmdd ');
V_ SQL: = 'alter table bl_test split partition pmax at (to_date (''' |
To_char (v_startdate + 1, 'yyymmdd') |
''', ''Yyyymmdd'') into (partition '| v_partname |
', Partition pmax )';
Execute immediate v_ SQL;
End loop;
End bl_partition;

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.