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.