4

I have the following table:

CREATE TABLE entries (id INT(10000) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstName VARCHAR(60), surname VARCHAR(60), course VARCHAR(250), subject VARCHAR(500), level VARCHAR(10), dateTime DATETIME);

But i'm getting the following error:

  ERROR 1439 (42000): Display width out of range for column 'id' (max = 255)

Any reason why the maximum is 255? I thought the maximum was 4294967295?

Any ideas?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Tom
  • 51
  • 1
  • 1
  • 5
  • 1
    possible duplicate of [What is the size of column of int(11) in mysql in bytes?](http://stackoverflow.com/questions/5634104/what-is-the-size-of-column-of-int11-in-mysql-in-bytes) – JuniorCompressor Mar 15 '15 at 23:53
  • Would be more useful if you actually answered – Tom Mar 15 '15 at 23:56
  • Read the duplicate. But since you need everything on your plate, 10000 isn't the maximum size but how many digits will be used to display the int. The integer will always have the same limits, no matter what you put inside the parentheses. – JuniorCompressor Mar 15 '15 at 23:58
  • Are you really trying to define a INT column which can display 10,000 digits? – Dijkgraaf Mar 15 '15 at 23:58
  • so should it be int(11) or int(255), and yes the id column could have 10000 entries – Tom Mar 16 '15 at 00:01
  • 1
    @Tom The number in parenthesis is the number of digits you need to display. If you want to display the number 100000 you just need int(6). But why bother with display precision at all? Just use int. – jpw Mar 16 '15 at 00:14

3 Answers3

3

You are creating an integer with display width of 10000 digits. MySQL apparently allows only 255 digits. You can't limit the maximum of an integer to arbitrary number in this way. Just use SMALLINT. That is closes to what you want.

btw. I like to set my ID columns as SERIAL. It's an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE. It is way wider than you aparently need. But it gets you some kind of standard for ID columns. The maximum value stored in this column is 18446744073709551615.

Fox
  • 2,348
  • 19
  • 19
1

It's the optional value that determines the number of digits displayed for the INT(10000) that has a maximum range of 255. It has nothing to do with the range of the int type. Just use INT or do INT(255) ZEROFILL if you really want to display a lot of digits...

For example, if you have an int(10) zerofill you would see

0000000001 for 1
0000001001 for 1001 
and so on...
jpw
  • 44,361
  • 6
  • 66
  • 86
0

It looks like 10000 digits is too much. Try something more sensible like |id INT NOT NULL AUTO_INCREMENT PRIMARY KEY" Good luck :)

dimacpp
  • 708
  • 1
  • 10
  • 13