Luo Hao

Oracle——自动按月分区

Rehoni / 2021-07-15


Oracle建分区表自动按月分区

 -- 自动按月分区
 create table EMS_RATIO
 (
     FUNCTION_ID VARCHAR2(64),
     FUNCTION_NAME VARCHAR2(256),
     FUNCTION_TYPE NUMBER(4),
     RESOLVE_TIME TIMESTAMP(0),
     MEASURE_TIME TIMESTAMP(0) not null,
     VOLTAGE VARCHAR2(32),
     START_STATION VARCHAR2(64),
     END_STATION VARCHAR2(64),
     RATED_CAPACITY FLOAT(24),
     LIMIT_I FLOAT(24),
     I FLOAT(24),
     P FLOAT(24),
     Q FLOAT(24),
     LOAD FLOAT(24),
     LOAD_TYPE NUMBER(4),
     ID VARCHAR2(32) not null,
     NAME VARCHAR2(64),
     constraint EMS_RATIO_PK
         primary key (ID, MEASURE_TIME)
 ) tablespace EMS_RATIO_TB
 partition by RANGE (MEASURE_TIME) interval (numtoyminterval(1,'month'))
 store in (EMS_RATIO_TB)(
     partition ems_ratio_partition values less than (to_date('2020-06-01','yyyy-MM-dd'))
 )