Home >Database >Mysql Tutorial >What data type is decimal in mysql?
DECIMAL is a high-precision data type used to store fixed-point decimals in MySQL. Its features include: precision (specified by (M, D)), range, no loss of precision, and storage space. It is often used in scenarios that require high-precision currency calculations, such as banking systems, accounting software, and e-commerce platforms.
What is the DECIMAL data type in MySQL?
DECIMAL is a data type in MySQL used to store fixed-point decimals. It is more precise than the FLOAT or DOUBLE data types because it uses a fixed number of decimal places.
Characteristics of DECIMAL:
Precision: DECIMAL The precision of the number of decimal places is fixed and determined by the data definition The (M, D) parameters are specified, where:
Uses of DECIMAL:
The DECIMAL data type is often used in scenarios that require high-precision currency calculations, such as:
Example:
The following statement creates an account named "amount " DECIMAL column, precision is (10, 2):
<code class="sql">CREATE TABLE transactions ( amount DECIMAL(10, 2) NOT NULL );</code>
This column can store values with a maximum precision of two decimal places and an integer part of up to 10 digits.
The above is the detailed content of What data type is decimal in mysql?. For more information, please follow other related articles on the PHP Chinese website!