top of page

Snack-Sized Data Basics
Data Types - Decimal Numbers

Decimal numbers are used whenever a whole number does not provide enough precision. Think money, weight and distance. Those extra decimal values provide important information.

For example, If we had $20.50, we wouldn't want to leave out those 50 cents!

​​

Screenshot 2025-02-19 at 11.29.04 AM.png

Before giving decimal data type examples, let’s clarify what "decimal digit precision" means. It refers to the total number of digits in a number, including those before and after the decimal point. A data type with a precision of 5 decimal digits can accurately represent up to 5 digits before rounding errors may occur.

​​​​​​​​

​

There are different types of decimal number data types used in SQL. Here are a few:​

  • REAL has approximately 7 decimal digits precision and uses 4 bytes of storage.​

  • DOUBLE has approximately 15 decimal digits precision and uses 8 bytes of storage.​

  • DECIMAL, also known as NUMERIC, lets us control the precision by specifying the total number of digits. The number of digits defined determines the amount of byte storage used.
    For example, DECIMAL(5, 2) allows up to five digits, with two digits occurring after the decimal point.​​

​​

​

Question:

Which of the above data types is most appropriate for storing salary information?

 

​Answer:

DECIMAL is more appropriate for money because it provides exact precision. 

decimals.gif
bottom of page