MySQL FAQs
FAQs Categories
Client Server Commands
Database Structure
Table Types or Storage Engines
Indexes
SQL Statements
Table Joins
Funtions and Operators
Tricky Select Queries
Speed Up Queries
Data Back Up
General Questions
Errors
1PLs Company - #1Payday.Loans Agency - Loans online and near me $100-$2500 (Same Day)
Powered by MySQL
 
Home / Database Structure / Data Types / Question No: 102

What is fixed point and decimal data type in MySQL?


Answer No: 102

In MySQL 5 Certification Study Guide, Numeric data types are described as below:

The fixed-point data type is DECIMAL. It is used to  represent exact-value numbers that have an integer part, a fractional part, or   both.

DECIMAL uses a fixed-decimal storage format: All   values in a DECIMAL column have the same number of decimal places and   are stored exactly as given when possible. DECIMAL values are not   processed quite as efficiently as FLOAT or DOUBLE values   (which use the processor's native binary format), but DECIMAL values   are not subject to rounding error, so they are more accurate. In other words,   there is an accuracy versus speed tradeoff in choosing which type to use. For   example, the DECIMAL data type is a popular choice for financial   applications involving currency calculations, because accuracy is most   important.

DECIMAL columns may be declared with a precision and   scale to indicate the number of significant digits and the number of decimal   places to the right of the decimal point. For example, if you want to represent   values such as dollar-and-cents currency figures, you can do so using a   two-digit scale:

cost DECIMAL(10,2)

The precision and scale can be omitted, or just the scale. The   defaults for omitted precision and scale are 10 and 0, respectively, so the   following declarations are equivalent:

total DECIMAL
total DECIMAL(10)
total DECIMAL(10,0)

The amount of storage required for DECIMAL column   values depends on the precision and scale. Approximately four bytes are required   per nine digits on each side of the decimal point.

The NUMERIC data type in MySQL is a synonym for   DECIMAL. (If you declare a column as NUMERIC, MySQL uses   DECIMAL in the definition.) Standard SQL allows for a difference   between the two types, but in MySQL they are the same. In standard SQL, the   precision for NUMERIC must be exactly the number of digits given in the   column definition. The precision for DECIMAL must be at least that many   digits but is allowed to be more. In MySQL, the precision is exactly as given,   for both types.

Related MySQL FAQs to the Above FAQ

What-is-BIT-Data-Type-in-MySQL What is BIT Data Type in MySQL?

What-are-numeric-data-types-in-MySQL What are numeric data types in MySQL?

What-are-integer-data-types-in-MySQL What are integer data types in MySQL?

What-are-float-data-types-in-MySQL What are float data types in MySQL?

What-is-MySQL-default-character-set What is MySQL default character set?

What-is-difference-between-binary-and-non-binary-string-data-types What is difference between binary and non-binary string data types?

What-are-ENUM-and-SET-Data-Types-in-MySQL What are ENUM and SET Data Types in MySQL?

What-is-difference-between-CHAR-AND-VARCHAR-data-types What is difference between CHAR AND VARCHAR data types?

What-are-string-data-types-in-MySQL-5 What are string data types in MySQL 5?

How-to-reformat-date-values-in-MySQL How to reformat date values in MySQL?

How-to-reformat-Time-values-in-MySQL How to reformat Time values in MySQL?

What-are-Temporal-Data-Types-in-MySQL What are Temporal Data Types in MySQL?

What-are-DATE-TIME-DATETIME-and-YEAR-Data-Types-in-MySQL What are DATE, TIME, DATETIME and YEAR Data Types in MySQL?

What-is-TIMESTAMP-Data-Type-in-MySQL What is TIMESTAMP Data Type in MySQL?

About FAQs: Recently Added FAQs

About MySQL FAQs: Site Map | Bookmark Us | Recommend this Site to Your Friend | Contact Us

Useful Links: Wikipedia.org | Oracle.com | w3schools.com | www.php.net | Github.com

© 2023  www.mysqlfaqs.net
All rights reserved.