Documentation Home
MySQL 5.6 リファレンスマニュアル
Download this Manual
PDF (US Ltr) - 26.8Mb
PDF (A4) - 26.9Mb
HTML Download (TGZ) - 7.1Mb
HTML Download (Zip) - 7.2Mb

11.2 数値型

MySQL はすべての標準 SQL 数値データ型をサポートします。これらの型は、概数値データ型 (FLOATREALDOUBLE PRECISION) だけでなく、真数値データ型 (INTEGERSMALLINTDECIMALNUMERIC) を含みます。キーワード INTINTEGER のシノニムで、キーワード DEC および FIXEDDECIMAL のシノニムです。MySQL では、DOUBLEDOUBLE PRECISION (非標準の拡張) のシノニムと見なされます。また、REAL_AS_FLOAT SQL モードが有効でないかぎり、REALDOUBLE PRECISION (非標準のバリエーション) のシノニムと見なされます。

BIT データ型は、ビットフィールド値を格納し、MyISAMMEMORYInnoDB、および NDB テーブルでサポートされています。

範囲外の値のカラムへの割り当てと、式の評価中のオーバーフローに対する MySQL での処理の詳細は、セクション11.2.6「範囲外およびオーバーフローの処理」を参照してください。



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.