Index column size too large. The maximum column size is 767 bytes.

在MySQL数据库上建立索引时,出现错误Index column size too large. The maximum column size is 767 bytes.
由于 MySQL Innodb 引擎表索引字段长度的限制为 767 字节,因此对于多字节字符集的大字段(或者多字段组合索引),创建索引会出现上面的错误。

解决方案

Step 1 :设置参数 innodb_large_prefix 为 ON

set global innodb_file_format = BARRACUDA;
set global innodb_large_prefix = ON;

Step 2:创建表的时候指定表的 row format 格式为 Dynamic 或者 Compressed
create table tb_name
(
  ……
) 
ROW_FORMAT=DYNAMIC ENGINE=InnoDB  DEFAULT CHARSET=utf8;
Step 3:对于已经创建的表修改表的row_format
alter table <table_name> row_format=dynamic;
alter table <table_name> row_format=compressed;

经过上述步骤之后,再继续创建索引就可以成功了。

alter table <table_name> add unique index(column_name);
  • 3
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值