索引列长度限制

包含索引的列,长度太长报错

数据库表,某一列 长度修改为 varchar(780)报错。原因是该列包含索引,mysql索引列有长度限制。

    ERROR 1071: Specified key was too long; max key length is 3072 bytes

    Operation failed: There was an error while applying the SQL script to the database.
    Executing:
    ALTER TABLE `xxx`.`new_table_test` 
    CHANGE COLUMN `col2` `col2` VARCHAR(780) NULL DEFAULT NULL ;
    
    ERROR 1071: Specified key was too long; max key length is 3072 bytes
    SQL Statement:
    ALTER TABLE `xxx`.`new_table_test` 
    CHANGE COLUMN `col2` `col2` VARCHAR(780) NULL DEFAULT NULL

一般默认最长是 767字节,通过如下设置,可以扩展到3072字节

set global innodb_large_prefix=1;
set global innodb_file_format=BARRACUDA;

你可能感兴趣的:(bug处理)