From: Martijn Tonies Date: January 7 2004 10:32am Subject: Re: max length of primary key List-Archive: http://lists.mysql.com/mysql/157041 Message-Id: <015f01c3d509$9e5ad240$0e02a8c0@martijn> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hi, > I have a problem when creating a table: > > > CREATE TABLE test ( > test_key varchar(255) NOT NULL default '', > test_value text NOT NULL, > PRIMARY KEY (test_key) ) TYPE=MYISAM; > > It then report error: > > mySQL Error: Specified key was too long. Max key length is 500 > > Why the varchar exceeded 500? > I have a "set-variable = default-character-set=utf8" in my.cnf, maybe > this is the cause of error? > And is there way to increase this 500 value? Or I must use InnoDB then? Apparently, the "500" number is "bytes". Assuming UTF8 takes at least two bytes/character, then yes, your VARCHAR(255) takes up more than 500 bytes. With regards, Martijn Tonies Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL Server. Upscene Productions http://www.upscene.com