I have to store a url inside a MySQL table. What is the best practice for determining a area which will hold a URL by having an undetermined length?
Values in VARCHAR posts are variable-length strings. The space could be specified like a value from to 255 before MySQL 5..3, and to 65,535 in five..3 and then versions. The effective maximum period of a VARCHAR in MySQL 5..3 and then is susceptible to the utmost row size (65,535 bytes, that is shared among all posts) and also the character set used.
< MySQL 5..3 use TEXT
>= MySQL 5..3 use VARCHAR(2083)
VARCHAR(512) (or similar) ought to be sufficient. However, because you don't fully realize the utmost entire Web addresses under consideration, I would go direct to
TEXT. The risk with this particular is obviously lack of efficiency because of
CLOBs being far reduced than the usual simple string datatype like
varchar(max) for SQLServer2005
varchar(65535) for MySQL 5..3 and then
This can allocate storage as need and should not affect performance.
I'm not sure about other browsers, but IE7 includes a 2083 character limit for HTTP GET procedures. Unless of course every other browsers have lower limits, I do not understand why you'd need anymore figures than 2083.
Most web servers possess a URL length limit (and that's why there's a mistake code for "URI too lengthy"), meaning there's an operating upper size. Discover the default length limit which are more popular web servers, and employ the biggest of these because the field's maximum size it ought to be ample.