Is it a good idea to keep INN in integer?

Inn contains only digits and is a string of characters (digits), length of 10 or 12 characters (depending on SP or LLC)

does it make sense to store this field in bitinteger or better in varchar(12) store?
while after the transfer to integer saw the inconvenience - in one of the programs this was now broken down into bits...

this field is used in various filters and important performance in queries.
need a serious answer.
April 3rd 20 at 17:22
5 answers
April 3rd 20 at 17:24
this field is used in various filters and important performance in queries


Search for the string of course more convenient, as it will allow you to search not only the row but also in her early using indexing features. The only advantage of storing in an Integer that saves space on hard, but it seems like this problem should be under the current penny hardware.
then, the more I realized that you need to keep in line even so. this is me in a chat asked why I don't keep them in integer. and my answer was - because sometimes the api Instead of the current INN returns every game and we write to the database. Apparently a framework that provides paid api is not immediately moderated, and sometimes the user enters incorrect information on their INN - if only it was filled.
are there any such records meet the type 000010550034 - muhammad.Weimann73 commented on April 3rd 20 at 17:27
@muhammad.Weimann73, the correctness of Russian was possible to check the formula
if it is incorrect, write the null, for example. - Keenan_Abbott commented on April 3rd 20 at 17:30
April 3rd 20 at 17:26
Tomorrow there will be the counterparty of the customs Union and will prove that not all was 10/12 characters and not all have the structure "only numbers".

But in General https://ofd.nalog.ru/statistics.html?level=2&fo&ssrf a little less than 6 million. Is there any sense to bother "optimizing" the search for such miniscule amounts?
you are right. hats off to you.
Besides, Belarus will soon become part of Russia, and there too, very different standards. - muhammad.Weimann73 commented on April 3rd 20 at 17:29
April 3rd 20 at 17:28
In other countries the tax codes are different, there are letters. Keep line.
April 3rd 20 at 17:30
Bad idea. INN may begin with a zero.
April 3rd 20 at 17:32
Everything vysheperechislennyh add that nothing prevents the tax to decide to add the letters in the INN, as it happened, for example, with the CSC.

Find more questions by tags MySQL