MySQL int 类型不是最多只能到 4,294,967,295 么,怎么会有 int(11)?
伊谢尔伦
伊谢尔伦 2017-04-17 11:17:05
0
6
796

MySQL int 类型不是最多只能到 4,294,967,295 么,怎么新建表的时候,默认不写 int 后面的数字(即不这样写int(5)),建好表之后会是 int(11)

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(6)
PHPzhong

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, 123 will be displayed as 00000000123

in int(11)
大家讲道理

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

Peter_Zhu

Is it okay?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template