Home >Database >Mysql Tutorial >MYSQLl数据库主键设置长度控制_MySQL

MYSQLl数据库主键设置长度控制_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 13:29:531137browse

bitsCN.com

MYSQLl数据库主键设置长度控制

 

1、出现的问题?

JEECMS套件(jeecms-2012-sp1)中有一个jeecms-db-2012-sp1.sql文件,文件里面有一张“jc_file”的表,表里面有一个字段“file_path”的长度是255,在安装此套件的过程中会报错,具体错误如下:

 

Query : CREATE TABLE `jc_file` (   `file_path` varchar(192) NOT NULL default '' COMMENT '文件路径',   `file_name` varchar(255) defau...Error Code : 1071Specified key was too long; max key length is 767 bytesExecution Time : 00:00:00:000Transfer Time  : 00:00:00:000Total Time     : 00:00:00:000---------------------------------------------------

 

 

错误的意思是,特殊键的字节长度不能超过767。

 

2、解决方案:

经测试,只要将“file_path” 的字段长度设置在192以内就可以了,191就可以。

 

3、附原表结构

CREATE TABLE `jc_file` (  `file_path` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '文件路径',  `file_name` VARCHAR(255) DEFAULT '' COMMENT '文件名字',  `file_isvalid` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '是否有效',  `content_id` INT(11) DEFAULT NULL COMMENT '内容id',  PRIMARY KEY  (`file_path`),  KEY `fk_jc_file_content` (`content_id`)) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT='文件资源表';

 

 

bitsCN.com
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn