MySQL Numeric Data types
Overview
In this tutorial, we will learn MySQL Numeric Data types. MySQL supports many data types to store numeric data, such as integer, floating-point, and fixed-point types.
Integer Data Types
The integer data type is used for storing whole numbers.
Whole numbers do not have decimal digits. For example, 25 is a whole number and 32.7 is not a whole number.
The following is the list of numeric data types:
Integer Data type | Description |
TINYINT | Used for very small integer |
SMALLINT | Used for small integer |
MEDIUMINT | Used for medium-sized integer |
INTEGER | Used for normal integer |
BIGINT | Used for large integer |
Floating-Point Data Types
The floating-point data types are used to represent approximate-value numbers that have an integer part, a fractional part, or both. The floating-point data types are:
FLOAT – Single-precision floating-point number
DOUBLE – Double-precision) floating-point number
These types represent values in the native binary floating-point format (IEEE 754).
Syntax
The FLOAT data type is assigned using the syntax:
FLOAT (N, D)
N is the maximum number of decimal digits and D is the number of digits following the decimal point. A single-precision floating-point integer is accurate to approximately 7 decimal places.
The DOUBLE data type is assigned using the syntax:
DOUBLE (N, D)
N is the maximum number of decimal digits and D is the number of digits following the decimal point. A double-precision floating-point integer is accurate to approximately 15 decimal places.
Fixed-Point Data Types
The fixed-point data type in MySQL is DECIMAL. DECIMAL data type is used to represent exact-value numbers that have an integer part, a fractional part, or both.
All values of the DECIMAL column have the same number of decimal places and are stored exactly as specified.
The DECIMAL data type is assigned using the syntax:
DECIMAL (N, D)
N is the maximum number of significant digits that can be stored and D is the number of digits following the decimal point (from 1 to 255).
—
MySQL Tutorials
MySQL Tutorials on this website:
https://www.testingdocs.com/mysql-tutorials-for-beginners/
For more information on MySQL Database: