MySQL char vs. int

后端 未结 4 1393
情话喂你
情话喂你 2021-01-22 09:55

I\'m currently having a discussion in my class about the datatypes char and int in MySQL. We have a phone number of 8 individual numbers. However, we c

4条回答
  •  野的像风
    2021-01-22 10:57

    Depends on how you want to represent the phone number, do you need area codes, country codes and stuff like that, and do you want to save it as a single column or do you want to split it up?

    Personally, I would choose to represent area codes, country codes, and the phone number as 3 columns with the datatype int, as this would make it easier to find all phone numbers in one area, and so on. But if it's only purpose is to be a like a string value, the char would be sufficient, however i would consider using the varchar instead, if you have phone numbers for several countries.`

提交回复
热议问题