电话号码和地址的mysql数据类型 [英] mysql datatype for telephone number and address

查看:153
本文介绍了电话号码和地址的mysql数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要输入电话号码,包括国家代码,分机号

I want to input telephone number in a form, including country code, extension

create table if not exists employee(    `   
      country_code_tel   int(11),
      tel_number         int(10),
      extension          int(10),
      mobile             bigint(20)
);

如果tel_number大于15位,我可以使用哪种数据类型,最好使用Bigint(20)?

If tel_number is larger than 15 bit, which datatype can I use, I'd better use Bigint(20)?

create table address(
      address           varchar(255),  
      city              varchar(255),
      country           varchar(255),
      post_code         int(11)
);

例如,如果我有加拿大的国家代码,则可以使用+2或002.哪个更适合处理?

For example, if I have a country code for Canada I can use +2 or 002. Which is better for processing?

感谢您的建议.

推荐答案

好吧,我个人不使用数字数据类型来存储电话号码或相关信息.

Well, personally I do not use numeric datatype to store phone numbers or related info.

您如何存储说001234567的数字?最终结果为1234567,丢失了前导零.

How do you store a number say 001234567? It'll end up as 1234567, losing the leading zeros.

当然,您始终可以将其左移,但前提是您确切知道该数字应为几位数.

Of course you can always left-pad it up, but that's provided you know exactly how many digits the number should be.

这不能回答您的全部帖子,
就是我的2美分

This doesn't answer your entire post,
Just my 2 cents

这篇关于电话号码和地址的mysql数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆