I have auto increment, primary key in MySQL called ID and it is INT. As my app grows and I'm getting more users they are making more entries. What happens when my INT comes to its maximum value 2 147 483 647? Can I just switch to BIGINT?
The MySQL
official documentation states that :
When the column reaches the upper limit of the data type, the next attempt to generate a sequence number fails. Use the UNSIGNED attribute if possible to allow a greater range.
And yes, you can switch the types of the auto_increment
value. On this point, the documentation advises to use :
[...] the smallest integer data type for the AUTO_INCREMENT column that is large enough to hold the maximum sequence value you will need.
Yes, you can alter the table and change from INT to BIGINT without problems.
Also, you may need to change the datatype wherever it is as an FK
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With