Phone Number Columns in a Database

后端 未结 10 1027
暗喜
暗喜 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 15:54

    Another reason I can think of not to store phone numbers as 'numbers' but as strings of characters, is that often enough part of the software stack you'd use to access the database (PHP, I am looking at you) wouldn't support big enough integers (natively) to be able to store some of the longer and/or exotic phone numbers.

    Largest number that 32-bits can carry, without sign, is 4294967295. That wouldn't work for just any Russian mobile phone number, take, for instance, the number 4959261234.

    So you have yourself an extra inconvenience of finding a way to carry more than 32-bits worth of number data. Even though databases have long supported very large integers, you only need one bad link in the chain for a showstopper. Like PHP, again.

提交回复
热议问题