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
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。