I want to create a database for a hotel reservation system.I want to store the phone number of the customer .What is the best data type for this?I like to use char(10)
.But I have a doubt about the size of the data type since the length of the t.p number varies in different countries.Whats the best option for this?
Asked
Active
Viewed 97 times
0

marc_s
- 732,580
- 175
- 1,330
- 1,459
-
so whats the question the data type or amount of characters? – YesItsMe Mar 28 '16 at 03:52
-
@yesitsme amount of characters – Mar 28 '16 at 03:54
-
1http://stackoverflow.com/a/723603/4535386 – YesItsMe Mar 28 '16 at 03:56
-
1Possible duplicate of [What's the longest possible worldwide phone number I should consider in SQL varchar(length) for phone](http://stackoverflow.com/questions/723587/whats-the-longest-possible-worldwide-phone-number-i-should-consider-in-sql-varc) – YesItsMe Mar 28 '16 at 03:56
-
Why `CHAR` in the first place, rather than VARCHAR? I don't think that padding phone numbers to a fixed size is actually helpful for anything, esp. since you'll be storing numbers from different countries. – Álvaro González Mar 28 '16 at 07:44
1 Answers
0
Many people will enter the phone number with the plus prefix (+), the IDD (country code), area code and phone number. Plus they may add spaces and/or parenthesis in various places.
Unless your are using a phone number parsing library, such as https://github.com/googlei18n/libphonenumber, I suggest char(32)
.

Richard Schneider
- 34,944
- 9
- 57
- 73