#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    51
    Rep Power
    3

    Data Types For Phone Numbers


    Just wondering what data type do you suggest if I'm trying to store phone numbers in ANSI SQL but specifically on a PostgreSQL database. They're all local 10 digit numbers so I was just going to do with CHAR or VARCHAR but I don't know if there's a recommended ANSI SQL data type I should use if I'm storing numbers like 5554566789 or 555-456-6789. Do you guys have any suggestions for me? Sorry this is the 1st time I've ever managed a database that required this data type.
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    724
    Rep Power
    291
    I store them like this [5555555555] and format them when I use them. I use validation to make sure they give me ten digits.
  4. #3
  5. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,024
    Rep Power
    4210
    Originally Posted by Vomster
    I store them like this [5555555555]
    eeeww, i don't like storing square brackets

    the secret to phone numbers is to use VARCHAR
    r937.com | rudy.ca
    please visit Simply SQL and buy my book
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    51
    Rep Power
    3
    Just curious why you recommend VARCHAR and if you do use it to store phone #'s, do you enter them in as 10 digits with no other characters? I know there's no correct or wrong way to do this but I like to know what is best practice among people who are more familiar with SQL than myself.
  8. #5
  9. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,024
    Rep Power
    4210
    Originally Posted by CarlosinFL
    Just curious why you recommend VARCHAR
    416 555-1212
    905 555-0937 ext 42

    Comments on this post

    • CarlosinFL agrees : Explained good information clearly for my simple brain.
    r937.com | rudy.ca
    please visit Simply SQL and buy my book
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Posts
    26
    Rep Power
    0
    And what about mobile/cell numbers? Where I live, they are totally different to landline numbers - a different number of digits to landline numbers. And a lot of small businesses only have mobile/cell numbers. Go for varchar.

IMN logo majestic logo threadwatch logo seochat tools logo