oracle数字格式上不需要的前导空格 [英] unwanted leading blank space on oracle number format

查看:69
本文介绍了oracle数字格式上不需要的前导空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在数字前加零(总共8位数字)进行显示.我正在使用oracle.

I need to pad numbers with leading zeros (total 8 digits) for display. I'm using oracle.

select to_char(1011,'00000000') OPE_NO from dual;
select length(to_char(1011,'00000000')) OPE_NO from dual;

我得到的不是"00001011",而是"00001011". 为什么我会得到额外的前导空白?完成此操作的正确数字格式字符串是什么?

Instead of '00001011' I get ' 00001011'. Why do I get an extra leading blank space? What is the correct number formatting string to accomplish this?

P.S.我意识到我可以只使用trim(),但是我想更好地理解数字格式.

P.S. I realise I can just use trim(), but I want to understand number formatting better.

@Eddie:我已经阅读了文档.但是我仍然不明白如何摆脱领先的空白.

@Eddie: I already read the documentation. And yet I still don't understand how to get rid of the leading whitespace.

@David:那是否意味着只能使用trim()?

@David: So does that mean there's no way but to use trim()?

推荐答案

使用FM(填充模式),例如

Use FM (Fill Mode), e.g.

select to_char(1011,'FM00000000') OPE_NO from dual;

这篇关于oracle数字格式上不需要的前导空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆