[英]change the format of the smallint datatype in mysql
I have a table with NUMBER as my PRIMARY KEY, the datatype is SMALLINT. 我有一个NUMBER作为我的PRIMARY KEY的表,数据类型是SMALLINT。 How do I format the values of that field so that instead of 1 it will dislay as 0001 and so on?
如何格式化该字段的值,使其代替为1,它将显示为0001,依此类推? Thanks!
谢谢! BTW I am using the mySQL workbench 5.2.40
顺便说一下,我正在使用mySQL工作台5.2.40
Change it to SMALLINT(4) ZEROFILL
. 将其更改为
SMALLINT(4) ZEROFILL
。 The zerofill will left-pad the number with zeroes to the specified length. zerofill将用零填充数字到指定的长度。
在我看来,格式化应该按需完成,而不是在模式中。
SELECT LPAD(id, 4, '0') FROM ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.