- Overview
- SQL Decimal stores numbers with decimal places as exact numbers
- Available in Oracle, SQL Server, MySQL, and Postgres
- NUMERIC is equivalent in SQL Server, MySQL, and Postgres
- Syntax and Structure
- DECIMAL type uses precision (p) and scale (s) parameters
- Precision specifies total digits, scale indicates decimal places
- Maximum precision and scale values vary by database
- Usage Examples
- Can store up to 20 total digits with precision 20 and scale 2
- Values must be within maximum precision range
- Can be converted to different decimal places using CONVERT or CAST
- Comparison with Other Types
- Float stores approximate numbers, unlike exact decimal
- Numeric is alias for Decimal in all supported databases
- SQL standard defines difference between NUMERIC and DECIMAL types