zoukankan      html  css  js  c++  java
  • mysql:[Err] 1075

    删除主键时,出错:[Err] 1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key

    alter table table_name drop primary key; # [Err] 1075

    这是因为,建表时,该主键设置的是自增属性:即AUTO_INCREMENT

    而自增列只能有1列,且这列必须为key,也就是建表的时候,如果是自增列,必须用primary key标识

    例如该表中的 (id) 这一列:

    create table if not exists table_name(
       id INT UNSIGNED AUTO_INCREMENT,
       name_people VARCHAR(40) NOT NULL,
       submission_time DATETIME,
       PRIMARY KEY(id)
    )ENGINE=InnoDB DEFAULT CHARSET=utf8;

    解决方法:

    建表时,不要加入自增属性,之后就可以删除主键,例如:

    create table if not exists table_name_2(
       id INT UNSIGNED,
       name_people VARCHAR(40) NOT NULL,
       submission_time DATETIME,
       PRIMARY KEY(id)
    )ENGINE=InnoDB DEFAULT CHARSET=utf8;

    然后可以删除主键:

    alter table table_name_2 drop primary key; 

    # 欢迎交流

  • 相关阅读:
    JdbcTemplate增删改查案例
    顾问和注解
    使用多种方式实现AOP
    面试题
    Spring Bean的生命周期和作用域
    IOC和AOP交互拓展(二)
    AOP
    错题
    Spring核心概念
    hadoop-MapReduce框架原理之OutputFormat数据输出
  • 原文地址:https://www.cnblogs.com/qi-yuan-008/p/11892575.html
Copyright © 2011-2022 走看看