Oracle如何显示小数点前面的0
这几天监控程序的运行状况,发日志在记录0.开头的小数时,都只显示了 .*****,查看程序,是这样用的:
select to_char(num) from AAAAAA,测试下:
SQL> select to_char(0.258) from dual;
TO_C
----
.258
确实用to_char()函数有这样的问题,查下资料
TO_CHAR (number) converts n to a value of VARCHAR2 datatype, using the optional number format fmt. The value n can be of type NUMBER, BINARY_FLOAT, or BINARY_DOUBLE. If you omit fmt, then n is converted to a VARCHAR2 value exactly long enough to hold its significant digits.
原来to_char在做转化时,如果你不指定可是,它就按它的格式去做转化,结果就把0给转不见了,所以在做转化时要给定格式
SQL> SELECT to_char(0.2588,'fm999990.99999') FROM dual;
TO_CHAR(0.258
-------------
0.2588
那个9可以根据情况进行增减,格式的个位数字要是0,不然也会显示不出来的。。
相关推荐
RealJianyuan 2020-06-14
秒懂数学 2014-01-26
xiaoge00 2019-10-19
dreamjava 2014-07-08
ykmail 2019-08-19
joyleeLyhua 2009-09-02
我壮壮壮 2019-07-01
一只懒虫 2016-08-18
xiahanss 2011-11-30
zluxingzhe 2019-06-27
xiaocaibai 2014-07-08
秒懂数学 2014-01-26
libowen0 2019-06-26
pfpfpfpfpf 2010-04-21
伊文硕Oracle 2013-03-21