number----char(to_char)

1,number----char(to_char)

一个数字在转成字符类型,在指定了格式时正数会多一个字节用来存储前面的‘+’
SQL> select length(23),length(-23) from dual;

LENGTH(23) LENGTH(-23)
---------- -----------
         2           3

SQL> select length(to_char(23)),length(to_char(-23)) from dual;

LENGTH(TO_CHAR(23)) LENGTH(TO_CHAR(-23))
------------------- --------------------
                  2                    3

SQL> select length(to_char(23,'99')),length(to_char(-23,'99')) from dual;

LENGTH(TO_CHAR(23,'99')) LENGTH(TO_CHAR(-23,'99'))
------------------------ -------------------------
                       3                         3

多出的占位符用空格补充
SQL> select length(to_char(23,'S99')),length(to_char(0,'S99')) from dual;

LENGTH(TO_CHAR(23,'STM9')) LENGTH(TO_CHAR(0,'S99'))
-------------------------- ------------------------
                         3                        3

                        
可以通过使用‘S’来显示‘+’
SQL> select to_char(23,'S99'),to_char(-23,'S99') from dual;

TO_CHAR(23,'S99') TO_CHAR(-23,'S99')
----------------- ------------------

SQL> select length(to_char(23,'TM9')),length(to_char(-23,'TM9')) from dual;

LENGTH(TO_CHAR(23,'TM9')) LENGTH(TO_CHAR(-23,'TM9'))
------------------------- --------------------------
                        2                          3
                        
TM最小格式输出,会去掉空格以及前面的‘+’,同不带格式参数一样
SQL> select length(to_char(23,'TM9')),length(to_char(-23,'TM9')) from dual;

LENGTH(TO_CHAR(23,'TM9')) LENGTH(TO_CHAR(-23,'TM9'))
------------------------- --------------------------
                        2                          3

                        
                       

成都创新互联专注于罗定企业网站建设,成都响应式网站建设公司,成都做商城网站。罗定网站建设公司,为罗定等地区提供建站服务。全流程定制网站,专业设计,全程项目跟踪,成都创新互联专业和态度为您提供的服务


名称栏目:number----char(to_char)
本文地址:http://ybzwz.com/article/iecooo.html