In SQL, the precision and scale of a number define its format and the range of values it can store.
Precision: The total number of digits a number can have, including digits on both sides of the decimal point.
Scale: The number of digits to the right of the decimal point.
Syntax
sql Copy code
NUMBER(precision, scale)
Examples
NUMBER(5, 2):
Precision = 5 (up to 5 total digits).
Scale = 2 (2 digits after the decimal point).
Valid values: 123.45, -12.34, 999.99.
NUMBER(6, 0):
Precision = 6.
Scale = 0 (integer values only).
Valid values: 123456, -98765.
NUMBER(8, 3):
Precision = 8 (total digits).
Scale = 3 (3 digits after the decimal).
Valid values: 12345.678, -12.345.
Key Points
The scale must always be less than or equal to the precision.
If scale is omitted, it defaults to 0 (integer).
If precision and scale are both omitted, the database allows a number of any size and scale.