简体   繁体   中英

Creating dynamic partition in Range partitioning

I have below scenario. Suppose I have a table which has 3 partition. one is for 20190201 next is 20190202 and one is for 20190210 . I have been given requirement. whichever date we pass automatic partition should be created. so if I am using dynamic sql I am able to create partition after the max partition for eg 20190211 . but if I want to create partition for 20190205 it is giving error. Is there anyway to create the partition at run time without data loss even when max partition exist. We have been told not to create interval partitioning

this is very simple.

while creating the table itself use interval partition on the date column. you can choose the partition interval as hour/day/month whichever you like.

so any time you insert a new data to the table based on the date value the data will go to correct partition or create a new partition. use the below syntax in your table while creating..

partition by range ( date_col )
interval ( NUMTODSINTERVAL(1,'day') )
( partition p1 values less then ( date '2016-01-01' ))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM