mysql 删除主键报错:1075

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 '积分记录详情表';
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值