Home > Database > Mysql Tutorial > Oracle如何显示小数点前面的0

Oracle如何显示小数点前面的0

WBOY
Release: 2016-06-07 17:33:56
Original
1717 people have browsed it

这几天监控程序的运行状况,发日志在记录0.开头的小数时,都只显示了 .*****,查看程序,是这样用的: select to_char(num) from

这几天监控程序的运行状况,发日志在记录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,不然也会显示不出来的。。

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template