How To Store Phone Numbers in MySQL

Store phone numbers as strings, not numbers.

  • Phone numbers are identifiers that happen to use digits.
  • Phone numbers starting with zero are valid, but may be interpreted as octal by a programming language.

Strip the phone number to only digits and store the extension in a separate field.

  • This will allow for uniform formatting later.

For US, strip the prepending ’1′ digit

  • Determine formatting based on length of the string (10 digits for US).

This entry was posted in Uncategorized. Bookmark the permalink.

One Response to How To Store Phone Numbers in MySQL

  1. Pingback: Masao Kitamura » MySQL Best Data Types For Common Types Of Data

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>