Phone Number Columns in a Database

后端 未结 10 1029
暗喜
暗喜 2021-01-01 15:32

In the last 3 companies I\'ve worked at, the phone number columns are of type varchar(n). The reason being that they might want to store extensions (ext. 333). But in every

10条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-01 16:08

    Stripping some characters and allowing others may have an impact if the database table is going to drive another system, e.g. IP Telephony of some sort. Depending on the systems involved, it may be legitimate to have etc.333 as a suffix, whereas the developers may not have accounted for "-" in the string (and yes, I am guessing here...)

    As for storing as a varchar rather than an int, this is just plain-ole common sense to me. As mentioned before, leading zeros may be stripped in an int field, the query on an int field may perform implicit math functions (which could also explain stripping "-" from the text, you don't want to enter 555-1234 and have it stored as -679 do you?)

    In short, I don't know the exact reasoning, but can deduce some possibilities.

提交回复
热议问题