日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

oracle to char trim,to_char前面多出空格

發布時間:2024/7/23 编程问答 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle to char trim,to_char前面多出空格 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

to_char前面多出空格

用to_char對數字時前面會多出一個空格。

SQL> select to_char(10,'00') from dual;

TO_

---

10 ? ? ?--前面有一個空格,這是一個正數的符號位

SQL> select length(to_char(10,'00')) from dual;

LENGTH(TO_CHAR(10,'00'))

------------------------

3 ? ? ? --所以長度是3

解決方法 :要么加 fm 要么加 trim

SQL> select length(to_char(10,'fm00')) from dual;

LENGTH(TO_CHAR(10,'FM00'))

--------------------------

2

SQL> select length(trim(to_char(10,'00'))) from dual;

LENGTH(TRIM(TO_CHAR(10,'00')))

------------------------------

2

網上有:

FM Fill mode. Oracle uses blank characters to fill format elements to a constant width equal to the largest element for the relevant format model in the current session language. For example, when NLS_LANGUAGE is AMERICAN, the largest element for MONTH is SEPTEMBER, so all values of the MONTH format element are padded to 9 display characters. This modifier suppresses blank padding in the return value of the TO_CHAR function: In a datetime format element of a TO_CHAR function, this modifier suppresses blanks in subsequent character elements (such as MONTH) and suppresses leading zeroes for subsequent number elements (such as MI) in a date format model. Without FM, the result of a character element is always right padded with blanks to a fixed length, and leading zeroes are always returned for a number element. With FM, which suppresses blank padding, the length of the return value may vary. In a number format element of a TO_CHAR function, this modifier suppresses blanks added to the left of the number, so that the result is left-justified in the output buffer. Without FM, the result is always right-justified in the buffer, resulting in blank-padding to the left of the number.

來自 “ ITPUB博客 ” ,鏈接:http://blog.itpub.net/25099483/viewspace-1064823/,如需轉載,請注明出處,否則將追究法律責任。

總結

以上是生活随笔為你收集整理的oracle to char trim,to_char前面多出空格的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。