Number (<p>, <s>)
Precision p value range: 1 ~ 38
Valid bit s value range:-84 ~ 127
Maximum integer digit = p-s
S is a positive number, and the specified position on the right of the decimal point starts rounding.
Negative Number of s. The specified position on the left of the decimal point starts rounding.
S is 0 or unspecified, rounded to the nearest integer
When p is less than s, it indicates that the number is a number with an absolute value less than 1, and the first s-p digit from the right of the decimal point must be 0, and the second decimal point is reserved.
-- 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;
|
A |
B |
C |
D |
E |
F |
1 |
123.3333 |
123.33 |
100 |
123 |
123 |
-0.00030 |
2 |
197.9333 |
197.93 |
200 |
198 |
198 |
0.00013 |
(Displayed in the pl/SQL dev SQL window)
-- Num_test end --------------------------------------------------------
The results seem to be correct, but now there is a problem. When I am not running in the pl/SQL dev window and I am running in isqlplus, the results will be a little different. Note, column F of row 1st:
A |
B |
C |
D |
E |
F |
123.3333 |
123.33 |
100 |
123 |
123 |
-0003 |
197.9333 |
197.93 |
200 |
198 |
198 |
. 00013 |
(Displayed in isqlplus)
It removes the last 0! The same effect can be tested with sqlplus.
However, my intention should be to retain the 0, because number () specifies the valid bit to be 5 after all.