Oracle 11g creates table partitioning by month with interval partitioning

Source: Internet
Author: User
Tags call shell

In the project database design process, because the data volume of the single table is very large, the table needs to be partitioned. Because the data in the table is a historical transaction, it is partitioned by month to improve the query and management.

Since we didn't know much about table partitioning before, in order to achieve the above features, we looked at a lot of information, the first direction was to automatically create partitions by month by crontab call shell scripts, or use Oracle's job call stored procedures to automatically create partitions. In the process of studying the two sets of scenarios, it is not possible to discover that oracle11g has an interval partition function, and for a range partition, you can automatically generate partitions by year, month, and days. The syntax is as follows:

creat TABLE TABLE1 (   table_id Number (8),   sub_date DATE,   VALUE number (8)) PARTITION by RANGE (sub_date) INTERVAL (Numtoyminterval (1, ' MONTH ')) (  PARTITION P1 VALUES less THAN (to_date (' 2014-05-01 ', ' yyyy-mm-dd '));


Data before May 1, 2014 will be placed in the P1 partition, and data from May 1 will automatically create a partition as soon as data is available.

Related Article

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.