MySQL数据类型 int什么意思
关注:136答案:2mip版
解决时间 -01-30 21:51
提问者叫我女王
-01-30 10:52
MySQL数据类型 int什么意思
最佳答案
二级知识专家那年仲夏
-01-30 12:08
从 -2^31 (-2,147,483,648) 到 2^31 – 1 (2,147,483,647) 的整型数据(所有数字)。存储大小为 4 个字节。int 的 SQL-92 同义字为 integer。
全部回答
1楼错过の花开
-01-30 13:32
int(m) zerofill,加上zerofill后m才表现出有点点效果,比如 int(3) zerofill,你插入到数据库里的是10,则实际插入为010,也就是在前面补充加了一个0.如果int(3)和int(10)不加 zerofill,则它们没有什么区别.m不是用来限制int个数的.int(m)的最大值和最小值与undesigned有关,最下面那副图有说明.
mysql> create table t (t int(3) zerofill);
query ok, 0 rows affected (0.00 sec)
mysql> insert into t set t = 10;
query ok, 1 row affected (0.00 sec)
mysql> select * from t;
+——+
| t |
+——+
| 010 |
+——+
1 row in set (0.11 sec)
zerofill with default width, the same as int(10):
mysql> create table t (t int zerofill);
query ok, 0 rows affected (0.02 sec)
mysql> insert into t set t = 10;
query ok, 1 row affected (0.02 sec)
mysql> select * from t;
+————+
| t |
+————+
| 0000000010 |
+————+
1 row in set (0.08 sec)
without zerofill:
mysql> create table t (t int);
query ok, 0 rows affected (0.01 sec)
mysql> insert into t set t = 10;
query ok, 1 row affected (0.01 sec)
mysql> select * from t;
+——+
| t |
+——+
| 10 |
+——+
1 row in set (0.00 sec)
我要举报
如以上问答内容为低俗/色情/暴力/不良/侵权的信息,可以点下面链接进行举报,我们会做出相应处理,感谢你的支持!
→点此我要举报以上信息!←
推荐资讯
大家都在看