为什么最好将电话号码存储为字符串而不是整数? [英] Why is it best to store a telephone number as a string vs. integer?

查看:255
本文介绍了为什么最好将电话号码存储为字符串而不是整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如问题所指出的那样,为什么将电话号码存储为字符串而不是整数存储在Telephone_number列中是最佳实践?

As the question states, why is it considered best practice to store telephone numbers as strings rather than integers in the telephone_number column?

不确定我了解的理由这个。

Not sure I understand the rationale for this. Please help clear this up!

谢谢!

推荐答案

电话号码是数字字符的字符串,不是整数。

Telephone numbers are strings of digit characters, they are not integers.

请考虑以下示例:


  • 用不同的基数表达电话号码会使其变得毫无意义

  • Expressing a telephone number in a different base would render it meaningless

将两个电话号码相加或相乘,或者对电话进行任何数学运算数字,毫无意义。结果不是另一个电话号码(出于明确原因除外)

Adding or multiplying two telephone numbers together, or any math operation on a phone number, is meaningless. The result is not another telephone number (except by conicidence)

电话号码旨在按原样输入连接的设备。

Telephone numbers are intended to be entered "as-is" into a connected device.

电话号码可能带有前导零。

Telephone numbers may have leading zeroes.

对电话号码的操作,例如添加区域代码,是字符串操作。

Manipulations of telephone numbers, such as adding an area code, are String operations.

存储电话号码的字符串版本可以使这一点明确而明确。

Storing the string version of the telephone number makes this clear and unambiguous.

历史记录:在旧的脉冲编码拨号系统上,电话号码中每个数字的编码以相同的脉冲数发送作为数字(或10个脉冲表示 0)。这也许就是为什么我们仍然使用数字来代表电话号码的一部分。请参见 http://en.wikipedia.org/wiki/Pulse_dialing

History: On old pulse-encoded dial systems, the code for each digit in a telephone number was sent as the same number of pulses as the digit (or 10 pulses for "0"). That may be why we still use digits to represent the parts of a phone number. See http://en.wikipedia.org/wiki/Pulse_dialing

这篇关于为什么最好将电话号码存储为字符串而不是整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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