title: How to assign N bytes to store integer instead of 4 bytes or 8 bytes in mysql?
body: <p>Lets assume I want to store Indian mobile phone numbers in a MySQL table, since the number of records is very large, I would want to optimize my storage.
  An Indian mobile phone number is 10 digits and usually starting with 7,8 or 9 .
  eg <code>9XXXXXXXXX</code> .</p>
  
  <p>Relevant MySQL fields are  :</p>
  
  <pre><code>Type    Storage     Minimum Value            Maximum Value
             (Bytes)        (Signed/Unsigned)     (Signed/Unsigned)
  
  INT      4         -2147483648                2147483647
                             0                  4294967295 &lt;-- somewhat small
  
  BIGINT   8       -9223372036854775808       9223372036854775807
                         0                18446744073709551615 &lt;-- too large
  </code></pre>
  
  <p>As seen, unsigned INT is little smaller ( about half in value ) , and unsigned BIGINT is very large to store a 10 digit number.
  5 bytes are sufficient to store this data .</p>
  
  <p>My questions are :-</p>
  
  <p>a) Is there a good way to assign custom number of bytes and store this data in MYSQL in any type of available data type ? </p>
  
  <p>b) Is this a premature optimization ? Is there any advantage/disadvantage at all trying to do this ?</p>
  
  <p>c) What are the benefits of having natural size datatypes like 4 byte and 8 byte numbers,and ignoring intermediate size like 5 byte and 6 byte in databases ?</p>
  
  <p>Note : Assume that 10 digit number is not a Phone number, but a 10 digit Integer. VARCHAR is not what I am looking for.</p>