Oracle Primary Keys: NUMBER vs. NUMBER (7.0)

Is there any use for determining accuracy on a PC? Is 7.0 enough, given that there are likely to be no more than a few thousand records?

Any danger not to indicate accuracy?

+5
source share
3 answers

NUMBER(7, 0) just limits the range of values.

Their internal representations do not differ:

CREATE TABLE t_pk (col1 NUMBER(7, 0) NOT NULL, col2 NUMBER(38) NOT NULL)

INSERT
INTO    t_pk
VALUES  (9999999, 9999999)

SELECT  DUMP(col1), DUMP(col2)
FROM    t_pk

DUMP(col1)                        DUMP(col2)
---                               ---
Typ=2 Len=5: 196,10,100,100,100   Typ=2 Len=5: 196,10,100,100,100

B Oracle, NUMBERare stored as significant digits of the numerical value normalized to 0.01 <= N < 1, and added to the exponent.

In the above example:

  • 196is an indicator 192( 4).
  • 10 is decimal 9
  • 100are decimal 99's

The whole number is read in decimal as 00.09 99 99 99 * (100 ^ 4) = 9,999,999

, , .

, .

, NUMBER(38), NUMBER(7, 0) ( , ).

, PRIMARY KEY , 0, , .

Update:

@Mac , , .

INT32, a NUMBER(9) ( , INT32).

+9

Quassnoi answer.

, , (, , ). , .NET, IDataRecord, ( ODP.NET), GetInt32 , NUMBER (38) , NUMBER (7) ( ).

+4

If you do not expect more than 100K entries in the table, if you specify PK with N (7.0), you will receive an early warning if any escape process results in overflow of the PC. If you specified it with N (38), the warning will not appear so early, perhaps.

I am always mistaken on the side of size limits to the smallest expected “product life” with a reasonable margin of error.

+2
source

All Articles