分区相关
oracle自动增加表空间指定分区
当前日期是 20230106,执行下面的语句后,往数据库插入数据,会自动新增 20230201 的一个分区(一定要插入数据才会新增分区)
如果时间字段是 DATE 类型:TO_DATE() 函数
create table testTable
(
tjsj DATE not null
)
tablespace tablespace_name
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
)
PARTITION BY RANGE(TJSJ)
INTERVAL (NUMTODSINTERVAL(1,'month')) store in ( tablespace_name)
(
PARTITION p_20230101 values LESS THAN (TO_DATE('2023-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS'))
tablespace tablespace_name
);
如果时间字段是 TIMESTAMP 类型:TIMESTAMP 函数
create table testTable
(
tjsj TIMESTAMP(6) default SYSDATE
)
tablespace tablespace_name
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
)
PARTITION BY RANGE(TJSJ)
INTERVA