Question

I've got a mysql database and I'm trying to put a url and unique id into two seperate fields. One of the urls are sometimes more than 800 characters long. I tried to create a UNIQUE index of the id and url, so that I'm not linking to the same url/id combo more than once, but I get an error regarding field length for the index.

I'm currently storing the url as a varchar. should I maybe be using blog? or something else? how will that effect the UNIQUE index?

Was it helpful?

Solution

Keep URL in a TEXT field, keep the MD5 hash of the URL in another column, and create a unique index on the hash column.

OTHER TIPS

I believe the size limit on varchar is 255. You should change from type varchar to text.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top