Best data type and length for use in MSISDN storage

What will be the best data type for storing MSISDN (phone number).

You must be able to store any phone number in the world.

Does anyone know the maximum possible length of MSISDN, including the international dialing code?

For example, phone numbers in South Africa are + 27xxxxxxxxx, which leads to 11 digits, excluding +

"+" does not need to be saved.

Thanks in advance

+6
source share
2 answers

I would use BIGINT. Please avoid using varchar at all costs. It is a very bad idea to use varchar or char.

Causes. Varchar / char takes up more space, performs slower searches and cross-references, and the index is also larger.

When designing tables, try to save them with a given string length, everything will work faster. If you need to have some kind of text field, it is better to use char instead of varchar, since the overhead for varchar is high.

I have been working in telecommunication companies for 12 years, developing / optimizing VoIP / SMS platforms. The number one killer when I come to fix systems is everywhere varchars.

Only my 0.02 is worth it.

+10
source

MSISDN is limited to 15 digits; prefixes are not included.

MSISDN in the GSM variant is created as:

MSISDN = CC + NDC (or NPA ) + SN CC = Country Code NDC = National Destination Code NPA = Number Planning Area SN = Subscriber Number 

Ideally, you do not need to save +. It just represents a way out.

The longest international phone code will only be used when making calls from Thuraya, which is 882 16. You can save this in another place.

If you plan to combine the International Dialing Code and MSISDN, you can use nvarchar (21) or varchar (21).

+3
source

Source: https://habr.com/ru/post/918637/


All Articles