Max key length error

2003-07-10 Thread Brian Rivet
Hi 
 
I'm new to MySql and I'm trying to set up a database table, and I keep
getting an error saying:
 
Max key length is 500
 
I have looked everywhere I can think of but I can't find an explanation
for what is causing the problem so I can fix it, can anyone help me?
 
Thanks,
 
Brian Rivet 


Re: Max key length error

2003-07-10 Thread Keith C. Ivey
On 10 Jul 2003 at 16:19, Brian Rivet wrote:

 Max key length is 500
 
 I have looked everywhere I can think of but I can't find an
 explanation for what is causing the problem so I can fix it, can
 anyone help me?

Presumably your key length is too long, but since you don't give us 
any clue about your table structure or indexes (by posting your 
CREATE TABLE statement, for example) what do you expect us to be able 
to say?

-- 
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]



Max Key Length Error

2003-07-10 Thread Brian Rivet
Sorry, I'm a little new at this, here's the statement:
 
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.
 
Thanks for any help you can give me.
 
Brian Rivet


Re: Max Key Length Error

2003-07-10 Thread Keith C. Ivey
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]