to_char函数对日期的转换:http://space.itpub.net/?uid-685769-action-viewspace-itemid-742918
to_char的fm:http://space.itpub.net/685769/viewspace-742915
1)9:表示一个数字,9的个数决定显示的宽度,如小数点后显示的小于实际数字,那么实际数字按照显示的位数四舍五入
SYS@ORA11GR2>select to_char('123','999999') as val from dual;
VAL
-------
123
SYS@ORA11GR2>
2)0:显示前导0,数字的实际位数与要求不符,没有要求的“宽”,那么以0补齐
SYS@ORA11GR2>select to_char('123','0999999') as val from dual;
VAL
--------
0000123
SYS@ORA11GR2>
3)$:显示美元符号
SYS@ORA11GR2>select to_char('123','$999999') as val from dual;
VAL
--------
$123
SYS@ORA11GR2>
4)L:浮动本地货币符号(这个与字符集有关系,如果是中文字符集,那么会显示¥)
SYS@ORA11GR2>select to_char('123','L999999') as val from dual;
VAL
-----------------
$123
SYS@ORA11GR2>
5).:小数点位置指定
SYS@ORA11GR2>select to_char('123','9999.99') as val from dual;
VAL
--------
123.00
SYS@ORA11GR2>
6),:显示逗号位置
SYS@ORA11GR2>select to_char('12345','999,999') as val from dual;
VAL
--------
12,345
SYS@ORA11GR2>
7)mi:负号显示在右侧
SYS@ORA11GR2>select to_char('-12345','999999mi') as val from dual;
VAL
-------
12345-
SYS@ORA11GR2>
8)pr:负数加上<>
SYS@ORA11GR2>select to_char('-12345','999999pr') as val from dual;
VAL
--------
<12345>
SYS@ORA11GR2>
9)eeee:科学技术法
SYS@ORA11GR2>select to_char('12345','999999eeee') as val from dual;
VAL
-------
1E+04
SYS@ORA11GR2>
10)v:乘以10的n次方,n次方的n即为v后面9的个数
SYS@ORA11GR2>select to_char('123','99999v99') as val1,123*100 as val2 from dual;
VAL1 VAL2
-------- ----------
12300 12300
SYS@ORA11GR2>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/685769/viewspace-742917/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/685769/viewspace-742917/