int(11) here does not mean the maximum number of digits represented, but the number of digits displayed. For example, 123 will be displayed as 00000000123
You don’t need to specify the length of int when creating a table. What is displayed in this () is the width displayed externally. Int is a fixed-length data type. So the storage size is determined. It will not change because of ().
The following numbers only affect the number of digits displayed by default
http://www.ccvita.com/175.html
举个例子最明白,类似于位数不足以0补全。
e.g.
mysql> create table joke (a int(11));
Query OK, 0 rows affected (0.01 sec)
mysql> insert into joke values(100);
Query OK, 1 row affected (0.00 sec)
mysql> select * from joke;
+------+
| a |
+------+
| 100 |
+------+
1 row in set (0.00 sec)
mysql> alter table joke change a a int(11) zerofill;
Query OK, 1 row affected (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> select * from joke;
+-------------+
| a |
+-------------+
| 00000000100 |
+-------------+
1 row in set (0.00 sec)
int(11) here does not mean the maximum number of digits represented, but the number of digits displayed. For example,
in int(11)123
will be displayed as00000000123
You don’t need to specify the length of int when creating a table. What is displayed in this () is the width displayed externally. Int is a fixed-length data type. So the storage size is determined. It will not change because of ().
If it is a signed integer, there will be an extra negative sign
Is it okay?