Jump to content

sql key error


lipun4u

Recommended Posts

I have arequirement 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.

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

Link to comment
Share on other sites

My version is...

 

mysql> select version();
+------------------+
| version()        |
+------------------+
| 5.1.32-community |
+------------------+
1 row in set (0.02 sec)

mysql>

 

If I remove the primary key and not null, everything is fine. What should I do ??

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.