Numeric data types in SQL are used to store numerical values, including integers and floating-point numbers.
I. NUMERIC DATA TYPES:
1. INTEGER or INT:
- Represents whole numbers without any decimal places.
- Typically used for counting or ordering data.
- Example:
INT
orINTEGER
.
2. SMALLINT:
- Similar to
INT
but with a smaller range of values. - Takes less storage space than
INT
. - Example:
SMALLINT
.
3. BIGINT:
- Represents large whole numbers.
- Has a larger range than
INT
. - Example:
BIGINT
.
4. DECIMAL or NUMERIC:
- Used for storing fixed-point numbers with exact precision.
- Requires a specified number of digits before and after the decimal point.
- Example:
DECIMAL(10, 2)
for a number with 10 total digits and 2 decimal places.
5. FLOAT:
- Represents floating-point numbers with approximate precision.