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.