views:

2726

answers:

4

What's the longest possible worldwide phone number I should consider in SQL varchar(length) for phone.

considerations:

  • + for country code
  • () for area code
  • x + 6 numbers for Extension extension (so make it 8 {space})
  • spaces between groups (i.e. in American phones +x xxx xxx xxxx = 3 spaces)
  • here is where I need your help, I want it to be worldwide

Consider that in my particular case now, I dont need cards etc. number begins with country code and ends with the extension, no Fax/Phone etc. comments, nor calling card stuff needed.

Thanks!

+7  A: 

It's a bit worse, I use a calling card for international calls, so its local number in the US + account# (6 digits) + pin (4 digits) + "pause" + what you described above.

I suspect there might be other cases

webclimber
You got a very good point.I added a few lines to my msg, pls read
Shimmy
Calling card redial should not be in the database, though - this is the part that gets added when dialling according to dial rules. Stored numbers should be in ISO form, without any dial related information.
TomTom
+14  A: 

Well considering there's no overhead difference between a varchar(30) and a varchar(100) if you're only storing 20 characters in each, err on the side of caution and just make it 50.

cletus
Just for the knowledge: so when IS there any overhead? please include a source in your answer, so we can go ahead and learn the basics from it.
Shimmy
I know that should be the case, but it's not always. In MySQL (for example) the full length is used for sorting. It's best to apply at least some minimal effort.
Morgan Tocker
When using a CHAR for example. SQL Server documentation (to and read it yourself) shows exactly that unused size in varchar is really not used, i.e. the overhead of unused chars is 0.
TomTom
+1  A: 

This seems to be related to what you're asking: Common mySQL fields and their appropriate data types.

sirlancelot
+2  A: 

In the GSM specification 3GPP TS 11.11, there are 10 bytes set aside in the MSISDN EF (6F40) for 'dialing number'. Since this is the GSM representation of a phone number, and it's usage is nibble swapped, (and there is always the possibility of parentheses) 22 characters of data should be plenty.

In my experience, there is only one instance of open/close parentheses, that is my reasoning for the above.

KevinDTimm