MySQL int 类型不是最多只能到 4,294,967,295 么,怎么新建表的时候,默认不写 int 后面的数字(即不这样写int(5)),建好表之后会是 int(11)
PHPz2017-04-17 11:19:05
The following numbers only affect the number of digits displayed by default
http://www.ccvita.com/175.html
怪我咯2017-04-17 11:19:05
举个例子最明白,类似于位数不足以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)
阿神2017-04-17 11:19:05
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
大家讲道理2017-04-17 11:19:05
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 ().