Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 37.8Mb
PDF (A4) - 37.9Mb
PDF (RPM) - 37.2Mb
HTML Download (TGZ) - 10.2Mb
HTML Download (Zip) - 10.3Mb
HTML Download (RPM) - 8.9Mb
Man Pages (TGZ) - 214.6Kb
Man Pages (Zip) - 327.6Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
Excerpts from this Manual

MySQL 5.7 Reference Manual  /  Data Types  /  Numeric Types

11.2 Numeric Types

MySQL supports all standard SQL numeric data types. These types include the exact numeric data types (INTEGER, SMALLINT, DECIMAL, and NUMERIC), as well as the approximate numeric data types (FLOAT, REAL, and DOUBLE PRECISION). The keyword INT is a synonym for INTEGER, and the keywords DEC and FIXED are synonyms for DECIMAL. MySQL treats DOUBLE as a synonym for DOUBLE PRECISION (a nonstandard extension). MySQL also treats REAL as a synonym for DOUBLE PRECISION (a nonstandard variation), unless the REAL_AS_FLOAT SQL mode is enabled.

The BIT data type stores bit values and is supported for MyISAM, MEMORY, InnoDB, and NDB tables.

For information about how MySQL handles assignment of out-of-range values to columns and overflow during expression evaluation, see Section 11.2.6, “Out-of-Range and Overflow Handling”.

For information about numeric type storage requirements, see Section 11.8, “Data Type Storage Requirements”.

The data type used for the result of a calculation on numeric operands depends on the types of the operands and the operations performed on them. For more information, see Section 12.6.1, “Arithmetic Operators”.

User Comments
  Posted by Carl Fischer on May 8, 2009
MySQL Float and Real values do not appear to handle all the IEEE standard floating point representations such as NaN, and +/- Inf. Special accommodations are needed to avoid accidentally inserting 0's for these values when integrating a MySQL database with a scientific application that generates these values.
  Posted by Oliver Pereira on February 10, 2010
Using the search feature to look for documentation on the type BOOL, this page is the highest ranked Reference Manual page that comes up. However, the term does not even appear on the page.

According to the page headed "10.1.1. Overview of Numeric Types", BOOL and BOOLEAN are synonyms for TINYINT(1).

I thought I should include that fact on this page, since the page does come up when searching for it. (Fixing the search feature would be a better solution, though!)
  Posted by stephen bond on February 23, 2010
bool deafulting to tinyint is not strict enough. if you really want bool type you should use type "bit(1)" which will allow you to use exactly 1 and 0 and maybe save space or use type "enum('T','F')" which will not save space but make it a true binary flag.
  Posted by Miroslav Šustek on October 29, 2010
Be careful when considering ENUM('T','F') as "true binary".

`val` ENUM('T','F') NOT NULL

mysql> INSERT INTO `bits` (`val`) VALUES ('W'), ('T'), ('F');
Query OK, 3 rows affected, 1 warning (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 1

| Level | Code | Message |
| Warning | 1265 | Data truncated for column 'val' at row 1 |
1 row in set (0.00 sec)

| 3 |
1 row in set (0.00 sec)

Well, shouldn't a binary type have only two distinct values?
(Note that it isn't NULL.)

Explanation from manual (10.4.4. The ENUM Type):
If you insert an invalid value into an ENUM (that is, a string not present in the list of permitted values), the empty string is inserted instead as a special error value. This string can be distinguished from a “normal” empty string by the fact that this string has the numeric value 0. More about this later.

If strict SQL mode is enabled, attempts to insert invalid ENUM values result in an error.
  Posted by Waheed Alshahnan on November 23, 2012
There is a know problem when using tinyint(1) and UNION look at bug: #61131
Sign Up Login You must be logged in to post a comment.