Oracle SQL: TO_CHAR and TO_NUMBER 笔记

Posted 微韩

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle SQL: TO_CHAR and TO_NUMBER 笔记相关的知识,希望对你有一定的参考价值。

 

(1)
select TO_CHAR(123.56,‘999.9‘) from dual; will return 123.6
select TO_NUMBER(‘123.56‘,‘999.9‘) from dual; will fail because of error "ORA-01722: invalid number"

(2)
select TO_CHAR(123.56,‘999‘) from dual; will return 124
select TO_NUMBER(123.56,‘999‘) from dual; will fail because of error "ORA-01722: invalid number"

(3)
select TO_CHAR(123.56,‘9999.99‘) from dual;will return 123.56
select TO_NUMBER(‘123.56‘,‘9999.99‘) from dual; will return 123.56

(4)
select TO_CHAR(123.56,‘9999‘) from dual; will return 124
select TO_NUMBER(‘123.56‘,‘9999‘) from dual; will fail because of error "ORA-01722: invalid number"

(5)
select TO_CHAR(123.56,‘99‘) from dual; will return ###
select TO_NUMBER(123.56,‘99‘) from dual; will fail because of error "ORA-01722: invalid number"

(6)
select TO_CHAR(123.56,‘999.99‘) from dual; will return 123.56
select TO_NUMBER(123.56,‘999.99‘) from dual; will return 123.56






















以上是关于Oracle SQL: TO_CHAR and TO_NUMBER 笔记的主要内容,如果未能解决你的问题,请参考以下文章

由 to_char 函数引起的 Oracle “Invalid Number”

oracle按天,周,月,季度,年查询排序

3.oracle 的过滤和模糊和排序

oracle查询语句中使用between and 查询效率高吗? 与to_char相比如何?

sql Oracle TO_CHAR函数

Oracle SQL TO_CHAR 可变长度