问题
My solution(months in german):
PARTITION BY LIST ((to_char(GEBURTSDATUM, 'Month')))
(
PARTITION p1 VALUES('JANUAR'),
PARTITION p2 VALUES('Februar'),
PARTITION p3 VALUES('MÄRZ'),
PARTITION p4 VALUES('APRIL'),
PARTITION p5 VALUES('MAI'),
PARTITION p6 VALUES('JUNI'),
PARTITION p7 VALUES('JULI'),
PARTITION p8 VALUES('AUGUST'),
PARTITION p9 VALUES('SEPTEMBER'),
PARTITION p10 VALUES('OKTOBER'),
PARTITION p11 VALUES('NOVEMBER'),
PARTITION p12 VALUES('DEZEMBER')
);
This doesn't work because of the to_char function.
回答1:
In 11g you can use function-based partitioning through defining a virtual column: http://www.oracle-base.com/articles/11g/partitioning-enhancements-11gr1.php#virtual_column_based_partitioning
Otherwise, you must manually define and maintain a separate column for the partitioning month.
I'd suggest using month numbers instead of names in either case.
回答2:
If the table has a date column, the statement below can be used as an example for monthly partitioning starting from today (Oracle 11g):
PARTITION BY RANGE (date_column)
INTERVAL (NUMTODSINTERVAL(1,'month') )
(PARTITION p_first VALUES LESS THAN ('16-MAY-2016'));
来源:https://stackoverflow.com/questions/14202945/oracle-partition-table-by-month