to_number, to_char用法简介

(1)to_number
http://hi.baidu.com/sunhuaj/blog/item/73bef9f44d745c64dcc47436.html
Converts a string to the NUMBER data type(将字符串转换为数字数据类型)
TO_NUMBER(<value>[, <format>, <NLS parameter>]) RETURN NUMBER
select   to_number('00001228')   from   dual;
to_number('00001228')
                1228
select   trunc(to_number('123.123'),2)   from   dual;
结果为:123.12
2、
Converts a HEX number to FLOAT(转换一个十六进制数的浮标)
TO_NUMBER(<value>, <format>);
SELECT TO_NUMBER('0A', 'XX')
FROM dual;
结果为:10
3、
Converts a HEX number to DECIMAL(一个十六进制数转换为十进制)
TO_NUMBER(<binary_float | binary_double | number>,
'<hex mask>') RETURN <binary_float | binary_double | number>;
SELECT TO_NUMBER(100000,'XXXXXXXX')
FROM dual;
结果为:1048576

(2) to_char
http://www.cnblogs.com/lyzxx/archive/2007/06/15/784902.html
to_char(1210.73, '9999.9') would return '1210.7'
to_char(1210.73, '9,999.99') would return '1,210.73'
to_char(1210.73, '$9,999.00') would return '$1,210.73'
to_char(21, '000099') would return '000021'

你可能感兴趣的:(to_number, to_char用法简介)