Set Length Control for MYSQLl database primary key

Source: Internet
Author: User
Welcome to the Linux community forum and interact with 2 million technical staff. 1. What are the problems? The JEECMS Suite (jeecms-2012-sp1) has a jeecms-db-2012-sp1. SQL file containing a jc_file table with a file_path field of 255 in length. An error is reported during installation of this suite, specific Error

Welcome to the Linux community forum and interact with 2 million technical staff> 1. What are the problems? JEECMS kit (jeecms-2012-sp1) has a jeecms-db-2012-sp1. SQL file containing a "jc_file" table with a field "file_path" with a length of 255, an error is reported during installation of this suite.

Welcome to the Linux community forum and interact with 2 million technicians>

1. Problems?

JEECMS kit (jeecms-2012-sp1) has a jeecms-db-2012-sp1. SQL file containing a "jc_file" table with a field "file_path" with a length of 255, an error is reported during installation of this suite. The specific error is as follows:

Query: create table 'jc _ file' ('file _ path' varchar (192) not null default ''comment' file path', 'file _ name' varchar (255) defau...

Error Code: 1071

Specified key was too long; max key length is 767 bytes

Execution Time: 00: 00: 00: 000

Transfer Time: 00: 00: 00: 000

Total Time: 00: 00: 00: 000

The error indicates that the length of the special key cannot exceed 767 bytes.

2. solution:

After testing, you only need to set the length of the "file_path" field to 192 or less.

3. Add the original table structure

Create table 'jc _ file '(

'File _ path' VARCHAR (255) not null default ''comment' file path ',

'File _ name' VARCHAR (255) DEFAULT ''comment' file name ',

'File _ isvalid' TINYINT (1) not null default '0' comment' valid ',

'Content _ id' INT (11) default null comment 'content id ',

Primary key ('file _ path '),

KEY 'fk _ jc_file_content '('content _ id ')

) ENGINE = innodb default charset = utf8 COMMENT = 'file resource table ';

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.