On 10 Jul 2003 at 16:33, Brian Rivet wrote:

> CREATE TABLE `TblUsers` (`UserId` INT(5) UNSIGNED DEFAULT NULL NOT
> NULL AUTO_INCREMENT, `FirstName` VARCHAR(255) DEFAULT 'unknown' NOT
> NULL, `LastName` VARCHAR(255) DEFAULT 'unknown' NOT NULL, `UserName`
> VARCHAR(255) DEFAULT 'unknown' NOT NULL, `UserPass` VARCHAR(255)
> DEFAULT 'unknown' NOT NULL , PRIMARY KEY (`UserId`), INDEX (`UserId`,
> `LastName`, `UserName`), UNIQUE (`UserId`, `UserName`))
> 
> It says the max key length is 500, I'm not sure what it's referring
> to, so I don't know what to fix.

INDEX (`UserId`, `LastName`, `UserName`) is made up of an INT and two 
VARCHAR(255)s, which is more than 500 characters.  You should use a 
prefix of the VARCHARs instead of the whole thing: INDEX (UserId, 
LastName(20), Username(20)) -- rather than 20 you can use whatever 
number is necessary to distinguish most of your strings (it doesn't 
matter much).

Also, the last index (UNIQUE(UserId, UserName)) is pointless, because 
UserId is already unique on its own.

-- 
Keith C. Ivey <[EMAIL PROTECTED]>
Tobacco Documents Online
http://tobaccodocuments.org


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to