日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql基础之四:int(M)中M的含义

發布時間:2025/3/15 数据库 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql基础之四:int(M)中M的含义 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

? 昨天寫sql文件時把以前一直不是很明白的地方弄明白了,就是在設置int型的時候,需要設置int(M),以前知道這個M最大是255,但是到底應該設置多少并沒有在意。

? 查了下官方manual?有這樣的語句:

?????M?indicates the?maximum display width?for integer types. The maximum legal display width is 255.

???? 這個M?就是maximum display width。那什么是maximum display width?看了下面的例子很容易說明了,注意zerofill?:

?

?mysql>?create table b ( b int (4));?
Query OK, 0 rows affected (0.25 sec)

mysql>?insert into b values (?12345?);?
Query OK, 1 row affected (0.00 sec)

mysql>?select * from b;?
+-------+
| b???? |
+-------+
| 12345 |
+-------+
1 row in set (0.00 sec)

mysql>?alter table b change b b int(11);?
Query OK, 1 row affected (0.00 sec)
Records: 1??Duplicates: 0??Warnings: 0

mysql>?select * from b;?
+-------+
| b???? |
+-------+
|?12345?|
+-------+
1 row in set (0.00 sec)

mysql>?alter table b change b b int(11)?zerofill?;?
Query OK, 1 row affected (0.00 sec)
Records: 1??Duplicates: 0??Warnings: 0

mysql>?select * from b?;
+-------------+
| b?????????? |
+-------------+
| 000000?12345?|
+-------------+
1 row in set (0.00 sec)

mysql>?alter table b change b b int(4)?zerofill?;?
Query OK, 1 row affected (0.08 sec)
Records: 1??Duplicates: 0??Warnings: 0

mysql>?select * from b?;
+-------+
| b???? |
+-------+
| 10000 |
+-------+
1 row in set (0.00 sec)

mysql>?alter table b change b b int(6)?zerofill?;?
Query OK, 1 row affected (0.01 sec)
Records: 1??Duplicates: 0??Warnings: 0

mysql>?select * from b;?
+--------+
| b??????|
+--------+
| 0?12345?|
+--------+
1 row in set (0.00 sec)

???? 以上的例子說明了,這個M?的表示顯示寬度,他跟著zerofill?一起才有意義。就算前面設置的M的值比數值實際的長度小對數據也沒有任何影響。

總結

以上是生活随笔為你收集整理的mysql基础之四:int(M)中M的含义的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。