create table if not exists table_name
(
id bigint auto_increment comment '主键id',
create_by varchar(64) not null comment '创建者',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
update_by varchar(64) null comment '更新者',
update_time datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
primary key (id, create_time)
)
comment '测试表名' partition by range (TO_DAYS(create_time)) (
partition P202401 values less than (TO_DAYS('2024-02-01')) ,
partition P202402 values less than (TO_DAYS('2024-03-01')) ,
partition P202403 values less than (TO_DAYS('2024-04-01')) ,
partition P202404 values less than (TO_DAYS('2024-05-01'))
);
|