注意:ZEROFILL默认的列为无符号,因此不能存储负数。
示例
创建一个临时表:b列设置为UNSIGNED ZEROFILL
CREATE TEMPORARY TABLE demo_a ( id INT(11) NOT NULL AUTO_INCREMENT, a INT(11) NOT NULL, b INT(11) UNSIGNED ZEROFILL NOT NULL, PRIMARY KEY (`id`) );
插入数值:
INSERT INTO demo_a(a,b) VALUES(1, 1);
结果:b列的左侧使用了0填充长度
mysql> SELECT * FROM demo_a; +----+---+-------------+ | id | a | b | +----+---+-------------+ | 1 | 1 | 00000000001 | +----+---+-------------+ 1 row in set (0.18 sec)
3. 参考资料
Integer类型:https://dev.mysql.com/doc/refman/5.6/en/integer-types.html
What does int(11) means in MySQL?:https://www.virendrachandak.com/techtalk/mysql-int11-what-does-it-means/
MySQL Integer类型与INT(11)
标签:prim tps unsigned ble big 临时表 maximum tab 存储