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
https://forums.phpfreaks.com/topic/178576-sql-key-error/
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
https://forums.phpfreaks.com/topic/178576-sql-key-error/#findComment-941923
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.