Oracle 11g Creates table partitions by month by means of interval partitions

Source: Internet
Author: User
Tags call shell

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

Since we didn't know much about table partitions before, we checked a lot of information to implement the above functions. At the beginning, we used Crontab to call Shell scripts to automatically create partitions on a monthly basis, you can also use Oracle jobs to call stored procedures to automatically create partitions. During the study of the above two sets of solutions, we did not intend to find that Oracle11g has an interval partition function. For Range partitions, partitions can be automatically generated by year, month, or day. Syntax:

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 ('1970-05-01 ', 'yyyy-MM-DD ')));


Data before January 1, May 1, 2014 will be placed in the p1 partition. As long as there is data in the data after January 1, May 1, a partition will be automatically created.

 

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.