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?
We're a place where coders share, stay up-to-date and grow their careers.
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?
James Sinkala -
Ajeeth thangarasu -
Nick Scialli (he/him) -
Nicolás Álvarez Tobón -
Discussion (2)
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.
Thanks Aditya