ERROR 1071 - Specified key was too long; max key length is 767 bytes IN MySQL

HI All, I want to add an index on a particular column but I'm getting this error message  : ERROR:1071 - Specified key was too long; max key length is 767 bytes
 Here is my table structure can anyone help me on how i can solve this issue. Thanks
Table           Create Table                                                                                                                                                                                                                                                                                                      
--------------  ---------------------------------------------------------------------------
tbl_properties  CREATE TABLE `tbl_Student` (                                                                                                                                                                                                                                                                                    
                  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,                                                                                                                                                                                                                                                                  
                  `Name` varchar(200) NOT NULL,                                                                                                                                                                                                                                                                                    
                  `library` varchar(5000) NOT NULL,                                                                                                                                                                                                                                                                              
                  `book` tinyint(1) NOT NULL DEFAULT '0',                                                                                                                                                                                                                                                                      
                  PRIMARY KEY (`Id`),                                                                                                                                                                                                                                                                                              
                  UNIQUE KEY `Name` (`Name`)                                                                                                                                                                                                                                                                                      
                ) ENGINE=InnoDB AUTO_INCREMENT=5645 DEFAULT CHARSET=latin1
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dan CraciunIT ConsultantCommented:
`library` varchar(5000) NOT NULL
That's your problem.

You're using MySQL 5.0?


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RotebergAuthor Commented:
No , I'm using 5.5
how can I fix it?
Dan CraciunIT ConsultantCommented:
Then that is not your problem :).
MySQL before 5.1 had a max length for varchar columns of 255 characters.

"max key length is 767 bytes" is triggered by one of the keys, probably this
UNIQUE KEY `Name` (`Name`)

If collation was UTF8, this would be normal. 200 characters * 4 bytes = 800 bytes, which is bigger than 767.
But in your case, latin1 should only take one byte/character.

Still, to test, make `Name` varchar(150)
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
first of all, you shouldn't make the "Name" as unique key, in real scenario, there's 2 or more different persons with exact the same names.

probably, you need to capture another unique identifier such as "NRIC/ Birth Number/ Passport Number" instead.

Hope this make sense to you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.