删除主键时,出错:[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; 

# 欢迎交流

mysql:[Err] 1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key的更多相关文章

  1. 解决,Incorrect table definition; there can be only one auto column and it must be defined as a key

    今天在迁移项目时,操作数据库报错: Incorrect table definition; there can be only one auto column and it must be defin ...

  2. ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key

    约束字段为自动增长,被约束的字段必须同时被key约束 没有设置成primary key 时,会报错. 加上primary key 则设置成功.

  3. Mysql运行SQL文件 错误Incorrect table definition;there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

    问题描述 想从服务器上DOWN下数据库.操作:先把数据库转存为SQL文件,然后在本地利用navicate运行SQL文件,出现错误信息: Incorrect table definition;there ...

  4. msyql同步的时候报错 : 错误代码: 1293 Incorrect table definition;there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

    场景,两个不同服务器上的数据库,进行数据库同步 但是执行之后,提示报错 错误代码: 1293 Incorrect table definition; there can be only one TIM ...

  5. 1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

    在数据库执行脚本文件时,执行到一半会遇到  这种问题: 出错处:2018-05-14 18:53:38 行号:712454 错误代码: 1293 - Incorrect table definitio ...

  6. Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

    错误描述 在DBeaver执行DDL语句时报错:SQL 错误 [1293] [HY000]: Incorrect table definition; there can be only one TIM ...

  7. mysql单表多timestamp报错#1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

    一个表中出现多个timestamp并设置其中一个为current_timestamp的时候经常会遇到#1293 - Incorrect table definition; there can be o ...

  8. Mysql --- Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

    我使用的5.5的mysql数据库会报这个错, 换成5.7的就可以了

  9. MySQL:Error : Tablespace for table '`database`.`temp`' exists. Please DISCARD the tablespace before IMPORT.解决办法

    今天在navicat上操作mysql数据库表,突然没有响应了.随后重启,mysql服务也终止了.随后启动服务,检查表,发现一张表卡没了,就重新添加一张表.报了一个错: Error : Tablespa ...

随机推荐

  1. 查询、下载GWAS目录数据的R包(gwasrapidd)

    目前GWAS方向发了很多文献,但是并没有一个很完善的R包对这些文献的数据进行汇总. 接下来推荐的这个是最新发表的GWAS数据汇总R包​.看了一下功能齐全,但是数据不是收录的很齐全​. 下面具体讲一下. ...

  2. bitmap以及异或运算法

    一 有40亿个整数,再给一个新的整数,需要判断新的整数是否在1亿个整数中. 此处需要用到bitmap方法,每个整数用一个bit表示,1表示存在,0表示不存在.因此一个4字节的int=32个bit也就是 ...

  3. webbench源码学习笔记

    学习内容 一共五百多行代码,其中包含了linux编程常用的API.可以通过学习源码,把不熟悉的API练习练习. 1 如何使用webbench (1)查看参数帮助 (2)运行方法 即以上模拟30个客户端 ...

  4. 【C++札记】指针数组和数组指针

    指针数组: 存储指针的数组,数组找那个的每个一元素都是指针 例: int* p1[4],p2[0]是一个指向int类型的指针 char* p2[4],p1[0]是一个指向char类型的指针 数组指针: ...

  5. css3 网页图片轮播的实现

    .lunbo{ height: 640px; width: 100%; background-position: -280px; margin-top: 103px; -webkit-animatio ...

  6. 笨办法学python 习题14 优化过 遇到问题的请看

    print "\t what's you name?"user_name = raw_input('>') from sys import argvscript, = arg ...

  7. Kafka 初识

    1.Kafka 是什么? 用一句话概括一下:Apache Kafka 是一款开源的消息引擎系统. 倘若“消息引擎系统“这个词对你来说有点陌生的话,那么“消息队列“.“消息中间件”的提法想必你一定是有所 ...

  8. M-SOLUTIONS Programming Contest

    A.(n-2)*180 #include<cstdio> #include<cstring> #include<iostream> #include<algo ...

  9. 使用lxml解析HTML代码

    做个参考,转自:https://blog.csdn.net/qq_42281053/article/details/80658018

  10. 阿里云最新Maven仓库地址 从此 我的maven依赖下载666~

    配置指南 maven配置指南 打开maven的配置文件(windows机器一般在maven安装目录的conf/settings.xml),在<mirrors></mirrors> ...