1075: Incorrect table definition; there can be only one auto column and it must be defined as a key(表定义不正确;只能有一个自增列,且必须将其定义为键)
MySQL含义
由于违反了 AUTO_INCREMENT 规则,表定义无效:一张表只能有一个自增列,且该列必须是某个键(PRIMARY KEY 或 UNIQUE/索引)的一部分。
原因
定义了多个 AUTO_INCREMENT 列,或 AUTO_INCREMENT 列不属于任何键(索引)。在 CREATE TABLE 或 ALTER TABLE 期间出现。
解决方法
只保留一个 AUTO_INCREMENT 列,并使其成为键的一部分:CREATE TABLE t (id INT AUTO_INCREMENT PRIMARY KEY, ...); 要修复现有表,先将该列加入键:ALTER TABLE t ADD PRIMARY KEY (id); 然后再定义 AUTO_INCREMENT。如果需要多个自增列,请重新审视设计;MySQL 不支持这样做。
同一数据库的其他条目
- 1615Prepared statement needs to be re-prepared(预处理语句需要重新准备)
- 1553Cannot drop index needed in a foreign key constraint(无法删除外键约束所需的索引)
- 3948Loading local data is disabled; this must be enabled on both the client and server sides(加载本地数据已禁用;必须在客户端和服务器端同时启用)
- 1055Expression not in GROUP BY (only_full_group_by)(表达式不在 GROUP BY 中)
- 1267Illegal mix of collations(非法的排序规则混用)
- 1030Got error N from storage engine(从存储引擎收到错误 N)
- 1197Multi-statement transaction required more than 'max_binlog_cache_size'(多语句事务所需空间超过了 'max_binlog_cache_size')