目标:浮点型数字在转字符的时候,有时候小数点前面的数“0”不显示,比如:数字:0.3312342, 转成字符之后变成了".3312342",为了避免这种情况需要对数据进行格式化,具体实验如下:
准备:
create table ttt (a1 varchar2(100), a2 number(16,4)); insert into ttt values('1111', 0.321312); insert into ttt values('1112', 22.321312); insert into ttt values('1113', 12.3212); insert into ttt values('1114', 42.321312); insert into ttt values('1115', 30.321312);
查询格式: select a1, to_char(a2, 'fm99990.999999'), to_char(a2) from ttt;