What kind of data do you use to store URIs in the database?

3

What kind of data do you use to store URIs in the database, taking into account an undetermined or very large URI length?

    
asked by anonymous 10.09.2016 / 03:00

1 answer

6

If you consider that URLs do not usually go over 2K in size and that VARCHAR in MySQL supports up to 65535 characters (the line also has this limit, so in practice it has to be a bit smaller. / p>

In theory, a URL can be larger in size, so if you want to guarantee it, it would be interesting to use a MEDIUMTEXT (16MB) or LONGTEXT (4GB). But I think a lot of nonsense, I would go from VARCHAR same, until it proves that it needs something bigger.

Obviously I discard any type other than text, at least in MySQL.

More details on What MySQL data types exist for texts? .

The question originally spoke in URL and then changed to URI. Still the same. There is more chance of URI going to be the size of a VARCHAR , but depending on how the URI is composed the better solution would be another.

    
10.09.2016 / 03:11