# What Is Numeric Data Type in Oracle?

//

Angela Bailey

What Is Numeric Data Type in Oracle?

In Oracle, the numeric data type is used to store numbers. It is important to choose the appropriate numeric data type depending on the range and precision of the numbers you want to store. Oracle provides a variety of numeric data types to cater to different requirements.

## Number Data Type

The NUMBER data type is the most commonly used numeric data type in Oracle. It stores both positive and negative numbers, with a precision ranging from 1 to 38 digits. The precision represents the total number of digits that can be stored, including both integer and fractional parts.

For example, if you specify NUMBER(5,2), it means you can store numbers with a maximum of 5 digits, out of which 2 digits can be used for the decimal part.

### Numeric Examples:

• NUMBER(10): A number with a maximum of 10 digits.
• NUMBER(6, 3): A number with a maximum of 6 digits, out of which 3 digits are used for the decimal part.
• NUMBER(3, -1): A number with a maximum of 3 digits before the decimal point and no decimal part.

## Floating-Point Numbers

If you need to store numbers with floating-point precision, Oracle provides two floating-point numeric data types: BINARY_FLOAT and BINARY_DOUBLE.

• BINARY_FLOAT: This data type is used to store single-precision floating-point numbers. It occupies 4 bytes of storage and can represent numbers with a precision of approximately 7 digits.
• BINARY_DOUBLE: This data type is used to store double-precision floating-point numbers. It occupies 8 bytes of storage and can represent numbers with a precision of approximately 15 digits.

## Decimal Data Type

The DECIMAL data type is used to store fixed-point decimal numbers. It is commonly used in financial applications where exact decimal values are required. The precision and scale need to be specified while defining the DECIMAL data type.

• DECIMAL(p): A decimal number with a maximum precision of p. The scale defaults to 0, meaning it does not allow any decimal part.
• DECIMAL(p, s): A decimal number with a maximum precision of p and a scale of s. The scale represents the number of digits that can be stored after the decimal point.

### Decimal Examples:

• DECIMAL(10): A decimal number with a maximum precision of 10 and no decimal part.
• DECIMAL(6, 2): A decimal number with a maximum precision of 6 and 2 digits after the decimal point.

In conclusion, Oracle offers various numeric data types to suit different needs. Choosing the appropriate numeric data type ensures efficient storage and accurate representation of numbers in your database.