mysql中定义字段时zerofill属性
一、字段中zerofill属性的类似定义方式
SQL语句:字段名 int(M) zerofill
二、zerofill属性的作用
1、插入数据时,当该字段的值的长度小于定义的长度时,会在该值的前面补上相应的0
2、zerofill默认为int(10)
3、当使用zerofill 时,默认会自动加unsigned(无符号)属性,使用unsigned属性后,数值范围是原值的2倍,例如,有符号为-128~+127,无符号为0~256。
三、实例
mysql> create table t (t int(3) zerofill);
mysql> insert into t set t = 10;
mysql> select * from t;
结果
010
参考资料:mysql中定义字段时zerofill属性 http://www.studyofnet.com/news/1332.html
SQL语句:字段名 int(M) zerofill
二、zerofill属性的作用
1、插入数据时,当该字段的值的长度小于定义的长度时,会在该值的前面补上相应的0
2、zerofill默认为int(10)
3、当使用zerofill 时,默认会自动加unsigned(无符号)属性,使用unsigned属性后,数值范围是原值的2倍,例如,有符号为-128~+127,无符号为0~256。
三、实例
mysql> create table t (t int(3) zerofill);
mysql> insert into t set t = 10;
mysql> select * from t;
结果
010
参考资料:mysql中定义字段时zerofill属性 http://www.studyofnet.com/news/1332.html
-
豆友218030979 赞了这篇日记 2021-04-08 14:25:09
-
已注销 赞了这篇日记 2021-01-22 10:24:21
热门话题 · · · · · · ( 去话题广场 )
- 2024豆瓣夏季摄影大赛 71.7万次浏览
- 离校那天 596.7万次浏览
- 哪一瞬间觉得自己运气真好 新话题
- 精神力夺回计划 4532次浏览
- 在livehouse里living 新话题
- 这座城市温柔的一面 67.4万次浏览