Page 1 of 1

sql column length error

Posted: Thu Oct 22, 2009 7:36 am
by lipun4u
I have a requirement that a table has to contain 3 columns, user_id, url and name. I want to make the url primary key. Go throw the following sql query.

Code: Select all

mysql> CREATE TABLE blog_details (
    -> user_id INT(11),
    -> blogname VARCHAR(1024),
    -> blogurl VARCHAR(1024) NOT NULL,
    -> PRIMARY KEY(blogurl),
    -> FOREIGN KEY (user_id) REFERENCES login(user_id)
    -> ON DELETE CASCADE
    -> );
ERROR 1071 (42000): Specified KEY was too long; max KEY length IS 767 bytes
How can I fix the above error ???

Re: sql column length error

Posted: Thu Oct 22, 2009 7:38 am
by Mark Baker
Besides asking why blogurl should be your primary key, and not simply uniquely indexed, your only solution is

Code: Select all

blogurl VARCHAR(767) NOT NULL

Re: sql column length error

Posted: Thu Oct 22, 2009 7:50 am
by lipun4u
thank you