Home >Database >Mysql Tutorial >PL/SQL number型数据

PL/SQL number型数据

WBOY
WBOYOriginal
2016-06-07 18:04:201170browse

PL/SQL number型数据

number(

,)

精度p取值范围1~38
有效位s取值范围-84~127

最高整数位数=p-s


s正数,小数点右边指定位置开始四舍五入
s负数,小数点左边指定位置开始四舍五入
s是0或者未指定,四舍五入到最近整数
当p小于s时候,表示数字是绝对值小于1的数字,且从小数点右边开始的前s-p 位必须是0,保留s位小数。


--num_test start------------------------------------------------

Connected to Oracle9i Enterprise Edition Release 9.0.1.1.1
Connected as aspire


SQL>
SQL> SET linesize 1000;
SQL> CREATE TABLE hjm_num_test
2 (a NUMBER,
3 b NUMBER(5,2),
4 c NUMBER(5,-2),
5 d NUMBER(5,0),
6 e NUMBER(5),
7 f NUMBER(2,5));

Table created

SQL> INSERT INTO hjm_num_test
2 (a,b,c,d,e,f) VALUES(123.3333,123.3333,123.3333,123.3333,123.3333,-0.0003);

1 row inserted

SQL> INSERT INTO hjm_num_test
2 (a,b,c,d,e,f) VALUES(197.9333,197.9333,197.9333,197.9333,197.9333,0.00012567);

1 row inserted

SQL> COMMIT;

Commit complete

SQL> SELECT * FROM hjm_num_test;

(在pl/sql dev sql窗口显示)

--num_test end--------------------------------------------------------

似乎结果很正确,可是现在出来一个问题,当我不在pl/sql dev窗口运行,我在isqlplus中运行,结果就有点不一样了,注意,第1行的F列:

(在isqlplus中显示)

它舍去了末尾的0!在sqlplus下测试也是同样的效果。

不过本人的意向应该是还是保留那个0的,因为number(2,5)它毕竟指定了有效位是5位。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn