MySQL mysql中auto_increment(整数)的限制是多少
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11264447/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the limit of auto_increment (integer) in mysql
提问by Eka
I have a mysql database in which i am using auto_increment(integer), can you tell me till what integer it can incremented. How we can increase the limit of auto_increment?
我有一个 mysql 数据库,我在其中使用 auto_increment(integer),你能告诉我它可以递增到什么整数。我们如何增加 auto_increment 的限制?
回答by Brendan Long
The limit of an auto_increment
column is the size of the column:
auto_increment
列的限制是列的大小:
Use a large enough integer data type for the AUTO_INCREMENT column to hold the maximum sequence value you will need. When the column reaches the upper limit of the data type, the next attempt to generate a sequence number fails. For example, if you use TINYINT, the maximum permissible sequence number is 127. For TINYINT UNSIGNED, the maximum is 255.
为 AUTO_INCREMENT 列使用足够大的整数数据类型来保存您需要的最大序列值。当列达到数据类型的上限时,下一次尝试生成序列号失败。例如,如果使用 TINYINT,则允许的最大序列号为 127。对于 TINYINT UNSIGNED,最大值为 255。
The limits of the integer typesare:
TINYINT - 127
UNSIGNED TINYINT - 255
SMALLINT - 32767
UNSIGNED SMALLINT - 65535
MEDIUMINT - 8388607
UNSIGNED MEDIUMINT - 16777215
INT - 2147483647
UNSIGNED INT - 4294967295
BIGINT - 9223372036854775807
UNSIGNED BIGINT - 18446744073709551615
回答by John Conde
Integer can go as high as 2147483647. If unsigned it can be 4294967295.
整数可以高达 2147483647。如果无符号它可以是 4294967295。
See this chartfor all of the integer values.