alter table integral_detail drop primary key
1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key
时间: 0.002s
删除建表语句中的自增auto_increment,其实我也没太搞明白,我表里面只有一个自增的列,报错提示只允许一个自增的列,实际我也没有多余自增的列。
报错的建表脚本:
create table integral_detail
(
id bigint not null auto_increment comment '主键id',
user_id varchar(32) comment '用户id',
code varchar(32) comment '编码(登录DL 阅读观看YD 评论PL 发帖FT 分享FX)',
score int comment '分值',
status varchar(2) default '0' comment '状态 0:正常 9:删除',
create_by varchar(32) not null comment '创建人',
create_time datetime not null default CURRENT_TIMESTAMP comment '创建时间',
update_by varchar(32) not null comment '修改人',
update_time datetime not null default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
primary key (id)
) comment '积分记录详情表';
修改之后的脚本:
-- 积分记录详情表(数据量大之后需要做分区)
create table integral_detail
(
-- 这里使用uuid,对于积分周期是按日,按周,按月,按年,批量生成积分明细(生成的时候主键用uuid),然后插入
id varchar(32) not null comment '主键',
user_id varchar(32) comment '用户id',
code varchar(32) comment '编码(登录DL 阅读观看YD 评论PL 发帖FT 分享FX)',
score int comment '分值',
status varchar(2) default '0' comment '状态 0:正常 9:删除',
create_by varchar(32) not null comment '创建人',
create_time datetime not null default CURRENT_TIMESTAMP comment '创建时间',
update_by varchar(32) not null comment '修改人',
update_time datetime not null default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '修改时间',
primary key (id)
) comment '积分记录详情表';