Data type for telephone numbers

Hey Jason, this is a very trivial question, but would you recommend storing telephone numbers as varchar?

This is a very subjective question. It's a difficult one in that to answer it in general terms requires me to mull over my mental collection of database heuristics, some of which seem to contradict each other. The easy answer is, "It depends." But if I'm forced to go one way or the other, here is my answer.

I generally use VARCHARs to store telephone numbers. Storage is not so expensive these days that I benefit that much from the savings found by storing them as numeric values. Also, I don't have to perform any numeric calculations on them, so I don't have to perform any type conversions.

If I store phone numbers as VARCHARs, I can also store formatting information such as dashes or parentheses. I can constrain the format with a check constraint like this:

create table MyTable 
( Name varchar(50),
  Phone varchar(15)
    check (Phone like '(???)???-????')
This can be expanded to support international numbers. Also, storing phone numbers as VARCHARs, I can easily filter rows by using the LIKE operator. The same kind of operation with numeric data is possible, though more complicated.

For More Information

  • What do you think about this answer? E-mail the edtiors at [email protected] with your feedback.

Dig Deeper on Oracle development languages