我正在尝试将 MySQL 表的引擎从“innodb”更改为“archive”。我遇到了以下错误:
我在 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/