mysql - 如何修复 "Too many keys specified; max 1 keys allowed"错误?

标签 mysql sql

我正在尝试将 MySQL 表的引擎从“innodb”更改为“archive”。我遇到了以下错误:

enter image description here

我在 stackoverflow 中寻找它但没有成功(我没有找到任何可用的答案)。知道如何解决这个问题吗?

最佳答案

您无法在 ARCHIVE 引擎中将 AUTO_INCRMENT 设置为特定值。因此,只需删除 auto_increment = 379 子句即可。

ARCHIVE 引擎不支持每个表有多个索引。您必须删除所有二级索引的 INDEX,最多保留一个索引。

事实上,我在 ARCHIVE 引擎中甚至没有使用过一个索引。我没有经常使用 ARCHIVE 引擎,不知道如何解决这个问题。

mysql> alter table t add key (x);
ERROR 1030 (HY000): Got error -1 from storage engine

在文档中找到它有点困难,但我确实找到了一些引用资料,表明 ARCHIVE 存储引擎根本不支持索引,尽管您收到的错误表明它支持 1 个索引。

https://dev.mysql.com/doc/refman/8.0/en/storage-engines.html说:

Archive: These compact, unindexed tables...

https://dev.mysql.com/doc/refman/8.0/en/archive-storage-engine.html说:

The ARCHIVE storage engine produces special-purpose tables that store large amounts of unindexed data in a very small footprint.

The AUTO_INCREMENT column can have either a unique or nonunique index. Attempting to create an index on any other column results in an error.

演示:

mysql> create table t ( x int auto_increment, key(x)) engine=archive;
Query OK, 0 rows affected (0.03 sec)

如果您尝试对可为空的列建立索引,它也不起作用。

mysql> create table t ( x int, key(x)) engine=archive;
ERROR 1121 (42000): Table handler doesn't support NULL in given index. Please change column 'x' to be NOT NULL or use another handler

您应该考虑为什么要使用 ARCHIVE 引擎。如果您尝试在更少的空间中存储数据,您可以使用带有 ROW_FORMAT=COMPRESSED 的 InnoDB 吗?

关于mysql - 如何修复 "Too many keys specified; max 1 keys allowed"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56280866/

相关文章:

sql - 如何打印导致ORA-01843错误的记录?

jquery - 在每 2 个用户的黑白字段中查找重复值的比率。 (MySQL)

sql - 数据库脚本按版本打包

MySQL 查询根据日期范围重叠选择不同的行

mysql - 长时间运行的 MYSQL 查询、Frame Table 和 View with grouping

主方案更改后 MySQL 复制失败

php - Laravel 4 - 数据排序

sql - 减去不同表的两列

mysql - Laravel Eloquent 中的多层次深度有很多关系

mysql - 地理编码 - 获取边界内的所有记录