DEV Community

loading...

What data type should I use in mysql

sosaheri profile image Heriberto Sosa ・1 min read

I always have problem choosing the correct data type for my tables for example. What should I use for store an url, an address or a phone number?

Can you share your recommendations?

Discussion (2)

pic
Editor guide
Collapse
adityamitra profile image
Aditya Mitra

For email, I would suggest a varchar of 255. I think that would work for almost all domain names and usernames.

For addresses, I would again go for varchars but a shorter length.
Like for city it would be 100. Same for state. Country code can be 2 depending upon your setup.
And for Address line 1 and 2, you can go for varchar 255

For phone numbers, I would use BIGINT considering that you already have the country code. But, your phone number should be be in the range of BIGINT in this case.

Collapse
sosaheri profile image