C:\Users\XXX>sqlplus / as sysdba SQL*Plus: Release 10.2.0.5.0 - Production on 星期日 8月 28 15:51:42 2016 Copyright (c) 1982, 2010, Oracle. All Rights Reserved. 连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options sys@XXX> select to_char(‘0.123‘,‘FM999999999990.00‘),0.123 from dual; TO_CHAR(‘0.123‘, 0.123 ---------------- ---------- 0.12 .123 sys@XXX> select to_char(‘0.125‘,‘FM999999999990.00‘),0.125 from dual; TO_CHAR(‘0.125‘, 0.125 ---------------- ---------- 0.13 .125
它的执行结果如下:
①其9代表:如果存在数字则显示数字,不存在则显示空格;
②其0代表:如果存在数字则显示数字,不存在则显示0,即占位符;
③其FM代表:删除如果是因9带来的空格,则删除之;
④四舍五入:0.125变成了0.13不知道大家注意到了没有。如果不要四舍五入,则需要trunc下;
时间: 2024-10-27 16:28:10