I have two tables with same column.

First table:

DESC orders;
Field           Type       Null Key      Default    Extra
order_id        int(8)     unsigned      zerofill   NO  PRI (null)auto_increment
customer_id     int(10)    unsigned      YES        MUL (null)  

Second table:

DESC items;
Field            Type      Null Key      Default    Extra
item_id          int(11)   unsigned      NO PRI (null)  auto_increment
order_id         int(10)   unsigned      NO PRI (null)  

Based on tables above order_id have different data precision.

But upon checking on information_schema database the precision is identical

INNER JOIN information_schema.TABLES t on t.TABLE_NAME = c.TABLE_NAME
WHERE c.TABLE_SCHEMA = 'database' AND c.COLUMN_NAME = 'order_id' and c.TABLE_NAME in ('orders','items');

The result was.

database         items      order_id    int         10                  MyISAM
database         orders     order_id    int         10                  MyISAM

Which of them is accurate? The one displayed in DESC table of the result from information schema? Thank you.


NUMBER_PRECISION is useless except for one case: ZEROFILL. Otherwise, it is an indication of how many columns of output are needed to display the largest number.

INT UNSIGNED needs 10 digits. INT SIGNED needs 11 columns -- a sign (if negative) and 10 digits.

Ignore the column there. Ignore it when you see int(11).

And don't bother declaring a column to be INT(100) or INT(2); it is still a 32-bit (4-byte) signed binary number.

| improve this answer | |
  • Meaning, values in information_schema is not accurate? – Darwin Cabiling Aug 29 '17 at 2:05
  • 1
    No, meaning that it refers to display width, not "numeric precision". Note that it includes room for the sign, which is not normally considered part of precision. 31 or 32 would be a 'correct' precision for signed or unsigned int, since it is stored in binary. – Rick James Aug 29 '17 at 2:09
  • Do you think I am going to have a problem in future if I leave those order_ids' in different precision? – Darwin Cabiling Aug 30 '17 at 0:27
  • For INT, inconsistent values of number_precision will not matter. (For DECIMAL, it may.) – Rick James Aug 30 '17 at 0:58
  • Alright on last confirmation, any precision declared in creating the column like column_1 INT(1) and column_2 INT(100) should hold up to 2,147,483,647? – Darwin Cabiling Aug 30 '17 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.