MySQL字段中zerofill的用途是什么?
Zerofill用零填充字段的显示值,直到列定义中指定的显示宽度为止。例如,如果column设置为int(8),则宽度为8。如果数字为4376,则将在左侧填充零以表示总宽度,即8-
00004376
让我们首先创建一个表-
mysql> create table DemoTable -> ( -> Number int(8) zerofill -> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values(10); mysql> insert into DemoTable values(1234); mysql> insert into DemoTable values(1); mysql> insert into DemoTable values(678965);
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
输出结果
这将产生以下输出-
+----------+ | Number | +----------+ | 00000010 | | 00001234 | | 00000001 | | 00678965 | +----------+ 4 rows in set (0.00 sec)
热门推荐
9 孙媳妇祝福语简短
10 小清新的祝福语简短
11 预祝高尔夫的祝福语简短
12 新年探亲祝福语简短精辟
13 宝宝生病简短祝福语大全
14 别人结婚舞台祝福语简短
15 中式婚礼贺词祝福语简短
16 表达家人的祝福语简短
17 白羊生日祝福语 简短独特
18 结婚婚庆祝福语简短