Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create this table? #1071 - Specified key was too long; max key length is 1000 bytes

Tags:

mysql

CREATE TABLE mini
(
realurl varchar(200) NOT NULL,
catagory varchar(200),
PRIMARY KEY (realurl,catagory),
FOREIGN KEY (realurl) REFERENCES main(realurl)
)

Error : `#1071 - Specified key was too long; max key length is 1000 bytes

Why I can't create this table? What should I change to create this table?

like image 488
Raplus Avatar asked Nov 16 '13 03:11

Raplus


1 Answers

PRIMARY KEY (realurl,catagory) has a size of (200 + 200) * 3 = 1,200 bytes, which is greater than the 1,000 byte limit, as MySQL stores utf8 encoded chars as 3 bytes.

You'll need to reduce the size of the the fields that make up the primary key or you can upgrade MySQL version to the latest release.

Also see this other question: Error: Specified key was too long; max key length is 1000 bytes.

like image 189
RSaha Avatar answered Sep 23 '22 13:09

RSaha