What does 5 of the INT (5) in MySQL mean?

Source: Internet
Author: User

for type int, MySQL supports specifying display width
For example:
Int (5): Indicates that if the numeric width is less than 5 bits, the width is filled and the total width is guaranteed to be 5 bits.
The default is int (11), and with Zerofill you can see the effect.

DROP TABLE IF EXISTS tab_5;

CREATE TABLE Tab_5
(id int (5))
Engine=innodb
DEFAULT Charset=utf8;

INSERT into Tab_5
VALUES (123);

INSERT into Tab_5
VALUES (12345);

INSERT into Tab_5
VALUES (1234567);

ALTER TABLE Tab_5
MODIFY ID Int (5) Zerofill;

mysql> SELECT ID from tab_5;
+---------+
| ID |
+---------+
| 00123 |
| 12345 |
| 1234567 |
+---------+
3 Rows in Set (0.00 sec)



What does 5 of the INT (5) in MySQL mean?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.