oracle number类型的格式化输出
2011-04-08 07:12
435 查看
问题:
解法:
原帖:http://topic.csdn.net/u/20110314/11/6459c365-ea61-4942-a22a-3a8a11c32899.html?seed=79231246&r=72139222#r_72139222
更多关于number类型,请参考:
1.http://www.ixora.com.au/notes/numeric_datatypes.htm
2.http://www.ixora.com.au/notes/number_representation.htm?number=12.00#example
3.http://blog.csdn.net/BOBO12082119/archive/2011/03/01/6215763.aspx
4.http://topic.csdn.net/u/20110307/13/e168a4d6-a5e6-434c-ac65-4ea620d7da12.html
输入的浮点数与小数位, input output ------- --------- 0.123 0.12 .123 0.12 .1 0.10 .199 0.20 123.199 123.1990
解法:
create table test_t( col_1 number(3,2), col_2 number(7,4) ); insert into test_t(col_1) values(0.123); insert into test_t(col_1) values(.123); insert into test_t(col_1) values(.1); insert into test_t(col_1) values(.199); insert into test_t(col_2) values(123.199); // 1.直接查询数据,就能显示效果 x number(p,s): p:x的有效位数,既x的宽度 s:x的小数位数 x的有效位数计算: s>=0,x的有效位:p s<0,x的有效位:p+|s| select * from test_t; COL_1 COL_2 ----- --------- 0.12 /*因为小数点只是2位,在进行存储时进行了四舍五入*/ 0.12 /*因为小数点只是2位,在进行存储时进行了四舍五入,当整数部分空缺时,在数据最左边补齐一个0*/ 0.10 /*当实际值的小数位数小于指定位数时,在数字最右边补齐0*/ 0.20 /*存储时进行了四舍五入*/ 123.1990 // 2.使用to_char()函数格式输出 SQL> select nvl(to_char(col_1,990.99),'Unknow') col_1, 2 nvl(to_char(col_2,990.9999),'Unknow') col_2 3 from test_t; COL_1 COL_2 ------- --------- 0.12 Unknow 0.12 Unknow 0.10 Unknow 0.20 Unknow Unknow 123.1990
原帖:http://topic.csdn.net/u/20110314/11/6459c365-ea61-4942-a22a-3a8a11c32899.html?seed=79231246&r=72139222#r_72139222
更多关于number类型,请参考:
1.http://www.ixora.com.au/notes/numeric_datatypes.htm
2.http://www.ixora.com.au/notes/number_representation.htm?number=12.00#example
3.http://blog.csdn.net/BOBO12082119/archive/2011/03/01/6215763.aspx
4.http://topic.csdn.net/u/20110307/13/e168a4d6-a5e6-434c-ac65-4ea620d7da12.html
相关文章推荐
- oracle 数据库,通过resultSet.getObject()获取时间类型截断的问题的解析(格式化时间不能完全输出,也就是只能到日,小时后面的没有了)
- 【SQL】oracle date类型格式化输出
- 查看oracle的number(20)类型数据为科学计数法的问题
- Oracle Number类型超长小数位为0问题
- oracle中number类型 默认长度是多少
- C语言整数类型及printf格式化输出问题总结复习及进制转换的简单实现
- oracle格式化输出小结
- oracle中的number类型用法及举例
- Oracle中数据类型number(m,n)
- [原创]在Oracle 10g,Number、Char和Varchar2类型作为主键,查询效率分析
- Oracle SQL2 (number数字类型函数)
- oracle number类型
- 修改有数据oracle字段类型 从number转为varchar
- Oracle集合类型输出参数的PL/SQL存储过程及其Java调用
- ORACLE存储之NUMBER类型
- 进击的KFC:第一节C数据类型、常量变量、运算符、表达式、格式化输入输出
- SQL Server 2005与Oracle同步注意NUMBER类型转换
- ORACLE数值类型的性能优化技巧number,Int,float
- ORACLE NUMBER类型详解