0

I haven't used MySQL for a long time and I forgot a lot, I'm developing a script that saves a list of URL's but I have a lot of doubts..

should I use varchar or text? (what is the difference)
Which characters should I escape?
what should be the length?
should I encrypt the URL's?

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by smantscheff
0

text data type is for very long texts. MySQL doesn't allow for indexes of more than 1024 characters, so you couldn't index a full length text field, but you can index the whole of a varchar field.
URLs can be more than 1.000 chars long, though. So if you plan to store URLs that long, you cannot index them in full length. Then you will need a hash value field with the MD5 or a similar hash value which can be indexed, and you cannot have a unique index for URLs that long.
Therefore chose varchar if you can guarantee that your URLs will have less than 256 chars, and text otherwise.
Set up the database and all connections in UTF-8 and don't worry any more about escaping and encoding.
What for would you encrypt URLs?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.