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前面多出空格相关推荐

  1. Oracle中CHAR类型不足位数时,用空格自动补足位数

    在今天开发过程中,发现了一查询结果很怪异,一GOOGLE下才知道是ORACLE对CHAR类型处理的问题,在ORACLE中对CHAR的处理是自动添加空格,比如char(8)存储'2007-11',则在后 ...

  2. oracle 并接去掉字符串,ORACLE删除字符-TRIM字符截取-substr查找字符-instr

    TRIM函数,最简单的功能就是来去除字符串的行首和行尾的空格,返回值类型是varchar2; 1.TRIM函数的完整语法描述 TRIM([{{LEADING | TRAILING | BOTH} [ ...

  3. 在Oracle中CHAR,NCHAR,VARCHAR,VARCHAR2,NVARCHAR2这五种类型的区别

    [在Oracle中CHAR,NCHAR,VARCHAR,VARCHAR2,NVARCHAR2这五种类型的区别 ] 1.CHAR(size)和VARCHAR(size)的区别  CHAR为定长的字段,最 ...

  4. oracle补齐字段,Oracle中CHAR类型自动补足空格的问题

    Oracle中CHAR类型自动补足空格的问题以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 在ORACLE中 CHAR类 ...

  5. oracle中char,varchar,varchar2的区别

    1.char长度固定,varchar2长度可变.例如,存储字符串"123",char(10)表示存储的内容占10个字节:123      (包含7个空格),varchar2(20) ...

  6. oracle exp不生成dumpfile,预估出实际导出文件的大小。

    oracle exp不生成dumpfile,预估出实际导出文件的大小. 目的:在不创建dumpfile前预估出需要的导出文件大小.  适用于export     实验步骤如下: OS:  Linux ...

  7. oracle中的trim函数使用介绍

    Oracle TRIM函数是很常见的函数,下面对Oracle TRIM函数的语法作了详尽的阐述说明,希望可以让您对Oracle TRIM函数有更深的认识. 如果提到Oracle TRIM函数,最简单的 ...

  8. oracle dbms_lob trim,oracle中的trim函数使用介绍

    Oracle TRIM函数是很常见的函数,下面对Oracle TRIM函数的语法作了详尽的阐述说明,希望可以让您对Oracle TRIM函数有更深的认识. 如果提到Oracle TRIM函数,最简单的 ...

  9. trim函数去掉字符串首尾空格

    trim():去掉字符串首尾的空格. public class trimDemo{public static void main(String arg[]){String a=" hello ...

最新文章

  1. Python使用matplotlib可视化箱图、seaborn中的boxplot函数可视化分组箱图、在箱图中添加抖动数据点(Dot + Box Plot)
  2. Foundation框架: 11.NSDate的基本认识和使用
  3. FileNotFoundError: Could not find module 'xxx.dll'. Try using the full path with constructor syntax.
  4. 干就行了!!!写程序就像珊瑚,分支太多,哪有那么多复用!
  5. 在上位计算机控制时不能将s7-200,plc控制系统编程题库.doc
  6. 针对开发人员的Microsoft SQL Server元数据
  7. 信息学奥赛一本通 1026:空格分隔输出 | OpenJudge NOI 1.1 06
  8. CSS基础必备知识点03
  9. require('module') 是什么?
  10. 【To Do】LeetCode 28. Implement strStr() 和KMP算法
  11. 说几个打工人要避开的坑
  12. 冒泡排序详解(C++)
  13. html5 最小化,当前界面最小化快捷键 窗口最小化和全屏化的快捷键是什么?
  14. P2825 [HEOI2016/TJOI2016]游戏
  15. 什么是前端开发工程师?
  16. Android 短视频 SDK 转场特效的音视频同步分析
  17. Murata村田高压电容的国产替代--赫威斯电容(HVC Capacitor)
  18. strcmp()函数详解
  19. 模板配置--后台管理系统
  20. 库编译:opencv 交叉编译静态库

热门文章

  1. Windows坐标系统
  2. 解决问题 com.alibaba.fastjson.JSONObject cannot be cast to xxx
  3. linux db2备份,db2实现备份
  4. linux实验总结及心得_安全实验室 | 内网渗透—Linux权限维持技巧总结
  5. python和python stub文件类型的区别_python – 如何告诉mypy包含stubfile
  6. jmeter 不同场景 比例_在JMeter测试中如何根据业务场景来控制运行比例
  7. IAR STM32报错Error[Pe147]:declaration is incompatible with“__nounwind __interwork __softfp unsigned
  8. opencv2.4.9报错找不到opencv_video249d.dll
  9. 【每日SQL打卡】​​​​​​​​​​​​​​​DAY 19丨行转列【难度中等】​
  10. itextPdf~将PDF页面大小转为A4格式