1

In using SequelPro it uses a default INT length (for display!) of 11 when creating a table. For example:

CREATE TABLE `tbl` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

My question is why does it do that, if the (11) is only used for display purposes if zerofill is enabled, which seems like such an odd property to have on by default and it's meaningless without it.

Update: Yes, I know that the (11) is the display width and does not change the byte-size of INT which is 4 in mysql. My question is why it uses the (11) AS A DEFAULT for the display-width-when-using-zero-fill in the application? I know writing all these caps is obnoxious, but no one seems to read the full question (there are 5 answers/comments that all say the same thing).

David542
  • 104,438
  • 178
  • 489
  • 842

2 Answers2

1

The number in the parenthesis i.e () does not determines the max and min values that can be stored in the integer field. The max and min values that can be stored are always fixed. It is just display width of integer data type.

Musa Ay
  • 167
  • 5
  • Yes, but it's a "suggested" display width, that MySQL informs to the client app as metadata, that could be aware (most likely not) of this property of the column. – The Impaler Nov 05 '21 at 19:29
  • @musa -- yes I'm aware. My question is why that is the default behavior. – David542 Nov 05 '21 at 19:33
1

MySQL supports the SQL standard integer types INTEGER (or INT) and SMALLINT. As an extension to the standard, MySQL also supports the integer types TINYINT, MEDIUMINT, and BIGINT. The following table shows the required storage and range for each integer type. 11.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT

MySQL Int types

LipESprY
  • 291
  • 2
  • 8