Datatype for URL

前端 未结 2 1160
渐次进展
渐次进展 2021-01-03 16:59

I read that the max length of URL can be 2,000 characters. I have therefore a table with varchar(2000) column type to store URLs. But this column can not be indexing only th

2条回答
  •  隐瞒了意图╮
    2021-01-03 18:00

    How about

    alter table myweb create FULLTEXT INDEX on myweb_idx1(url);

    Although I have to agree with zerkms that a 1000 char index should be more than enough, considering the fact that you are very unlikely to encounter a url longer than that, and even then the 1000 char prefix should do a fine job.

    Regarding your original question: I think it's safe to save URLs in varchars. Where are these urls coming from ? Who's the producer of the data? You can probably enforce limits.

    If you're crawling the web for urls, then you are almost certainly not going to happen upon a 2000 char url , cause the only way I can imagine getting there would be with GET data.

    Hope this rambling makes sense.

提交回复
热议问题