Number Data Type

1.     NUMBER is used to store numeric values in Oracle.

2.     Can store integers, decimals, and floating-point numbers.

3.     Supports optional precision (total digits) and scale (digits after the decimal).

4.     Syntax: NUMBER(p,s) where p is precision and s is scale.

5.     Maximum precision is 38 digits.

6.     If precision and scale are omitted, it can store any valid number.

7.     Can store positive and negative values.

8.     Used for arithmetic operations in SQL and PL/SQL.

9.     Takes variable storage depending on the value.

10.  Ideal for storing IDs, amounts, counts, or calculations.

Precision and Scale

1.     Precision is the total number of digits.

2.     Scale is the number of digits to the right of the decimal.

3.     Maximum precision is 38 digits.

4.     Scale can be negative.

5.     Default precision allows up to 38 digits.

6.     Default scale is 0 for integers.

7.     Precision must be between 1 and 38.

8.     Scale can range from -84 to 127.

9.     Scale cannot be greater than precision.

10.  Storage is variable-length depending on digits stored.

Data Type

Sample Value

Explanation

NUMBER

0

Zero value

NUMBER

1

Small positive integer

NUMBER

-1

Small negative integer

NUMBER

100

Positive integer

NUMBER

-100

Negative integer

NUMBER(5)

12345

Integer up to 5 digits

NUMBER(5)

-54321

Negative integer up to 5 digits

NUMBER(7,2)

12345.67

Total 7 digits, 2 decimal places

NUMBER(7,2)

-12345.67

Negative with 2 decimal places

NUMBER(10,0)

9876543210

Large integer, no decimal

NUMBER

0.0001

Small positive decimal

NUMBER

-0.0001

Small negative decimal

NUMBER

1E5

Scientific notation (100,000)

NUMBER

1.23E4

Scientific notation with decimal

NUMBER

-1.23E4

Negative scientific notation

NUMBER

NULL

No value

NUMBER(3,1)

12.3

Total 3 digits, 1 decimal

NUMBER(3,1)

-9.8

Negative decimal with 1 place

NUMBER(8,3)

12345.678

Total 8 digits, 3 decimal places

NUMBER

9999999999999999999999999999

Very large number, up to 38 digits


No comments:

Post a Comment