mysql5.6索引长度,最大676字节

因此建立联合索引时,需要注意长度,如下表能建立成功,如果去掉长度限制变成:,`wu`), 那么就会创建表失败。

 

create table `table_name` (
`id` bigint(20) not null auto_increment comment '主键',
`address` varchar(255) default 'work' ,
`action` varchar(255) default null ,
`city` varchar(255) default null ,
`concurrent` int(11) default null ,
`created` datetime not null,
`created_by` varchar(255) not null,
`modified` datetime not null,
`modified_by` varchar(255) not null,
`name` varchar(255) not null comment '名称',
`wu` varchar(255) not null comment 'wuhan',
primary key (`id`),
unique key `name` (`name`(180),`wu`(60)),
key `idx_city` (`city`)
) engine=innodb default charset=utf8mb4 comment='信息';