Issues faced with int(11) datatype in MYSQL

后端 未结 2 657
渐次进展
渐次进展 2021-01-15 18:25

I have a table in MYSQL in with a primary key id int(11) (auto-incremented). Now I have a program which reads some text file and enters the value in id column. So my table s

2条回答
  •  囚心锁ツ
    2021-01-15 18:46

    INT in MySQL is 32 bits. INT(11) likely means you have a signed INT, which for an ID is useless. Changing it to an unsigned INT will automatically double the number of IDs available (since nobody uses a negative ID). Even though 11 "seems" bigger, it's because it takes into consideration the "length" of the number if it's the maximum negative number (-2147483648) which is 11 characters long.

    BIGINT will let you go up to 64 bits, signed or unsigned. Again, unsigned will allow you twice as many IDs (>0).

    As Andrew mentioned above, if your PHP does not support 64 bit integers then you will not be able to easily use them.

    Hope that helps.

提交回复
热议问题