PDF (A4) - 43.4Mb
Man Pages (TGZ) - 297.2Kb
Man Pages (Zip) - 402.4Kb
Info (Gzip) - 4.3Mb
Info (Zip) - 4.3Mb
MySQL Globalization
MySQL Information Schema
MySQL Installation Guide
Security in MySQL
Starting and Stopping MySQL
MySQL and Linux/Unix
MySQL and Windows
MySQL and macOS
MySQL and Solaris
Building MySQL from Source
MySQL Restrictions and Limitations
MySQL Partitioning
MySQL Tutorial
MySQL Performance Schema
MySQL Replication
Using the MySQL Yum Repository
MySQL NDB Cluster 8.0
For integer data types,M indicates the minimum display width. The maximum display width is 255. Display width is unrelated to the range of values a type can store, as described inSection 13.1.6, “Numeric Type Attributes”.
For floating-point and fixed-point data types,M is the total number of digits that can be stored.
As of MySQL 8.0.17, the display width attribute is deprecated for integer data types; you should expect support for it to be removed in a future version of MySQL.
If you specifyZEROFILL for a numeric column, MySQL automatically adds theUNSIGNED attribute to the column.
As of MySQL 8.0.17, theZEROFILL attribute is deprecated for numeric data types; you should expect support for it to be removed in a future version of MySQL. Consider using an alternative means of producing the effect of this attribute. For example, applications could use theLPAD() function to zero-pad numbers up to the desired width, or they could store the formatted numbers inCHAR columns.
Numeric data types that permit theUNSIGNED attribute also permitSIGNED. However, these data types are signed by default, so theSIGNED attribute has no effect.
As of MySQL 8.0.17, theUNSIGNED attribute is deprecated for columns of typeFLOAT,DOUBLE, andDECIMAL (and any synonyms); you should expect support for it to be removed in a future version of MySQL. Consider using a simpleCHECK constraint instead for such columns.
SERIAL is an alias forBIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE.
SERIAL DEFAULT VALUE in the definition of an integer column is an alias forNOT NULL AUTO_INCREMENT UNIQUE.
When you use subtraction between integer values where one is of typeUNSIGNED, the result is unsigned unless theNO_UNSIGNED_SUBTRACTION SQL mode is enabled. SeeSection 14.10, “Cast Functions and Operators”.
A bit-value type.
Mindicates the number of bits per value, from 1 to 64. The default is 1 ifMis omitted.TINYINT[(M)] [UNSIGNED] [ZEROFILL]A very small integer. The signed range is
-128to127. The unsigned range is0to255.These types are synonyms for
TINYINT(1). A value of zero is considered false. Nonzero values are considered true:mysql> SELECT IF(0, 'true', 'false');+------------------------+| IF(0, 'true', 'false') |+------------------------+| false |+------------------------+mysql> SELECT IF(1, 'true', 'false');+------------------------+| IF(1, 'true', 'false') |+------------------------+| true |+------------------------+mysql> SELECT IF(2, 'true', 'false');+------------------------+| IF(2, 'true', 'false') |+------------------------+| true |+------------------------+However, the values
TRUEandFALSEare merely aliases for1and0, respectively, as shown here:mysql> SELECT IF(0 = FALSE, 'true', 'false');+--------------------------------+| IF(0 = FALSE, 'true', 'false') |+--------------------------------+| true |+--------------------------------+mysql> SELECT IF(1 = TRUE, 'true', 'false');+-------------------------------+| IF(1 = TRUE, 'true', 'false') |+-------------------------------+| true |+-------------------------------+mysql> SELECT IF(2 = TRUE, 'true', 'false');+-------------------------------+| IF(2 = TRUE, 'true', 'false') |+-------------------------------+| false |+-------------------------------+mysql> SELECT IF(2 = FALSE, 'true', 'false');+--------------------------------+| IF(2 = FALSE, 'true', 'false') |+--------------------------------+| false |+--------------------------------+The last two statements display the results shown because
2is equal to neither1nor0.SMALLINT[(M)] [UNSIGNED] [ZEROFILL]A small integer. The signed range is
-32768to32767. The unsigned range is0to65535.MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL]A medium-sized integer. The signed range is
-8388608to8388607. The unsigned range is0to16777215.INT[(M)] [UNSIGNED] [ZEROFILL]A normal-size integer. The signed range is
-2147483648to2147483647. The unsigned range is0to4294967295.INTEGER[(M)] [UNSIGNED] [ZEROFILL]This type is a synonym for
INT.BIGINT[(M)] [UNSIGNED] [ZEROFILL]A large integer. The signed range is
-9223372036854775808to9223372036854775807. The unsigned range is0to18446744073709551615.SERIALis an alias forBIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE.Some things you should be aware of with respect to
BIGINTcolumns:All arithmetic is done using signed
BIGINTorDOUBLEvalues, so you should not use unsigned big integers larger than9223372036854775807(63 bits) except with bit functions! If you do that, some of the last digits in the result may be wrong because of rounding errors when converting aBIGINTvalue to aDOUBLE.MySQL can handle
BIGINTin the following cases:When using integers to store large unsigned values in a
BIGINTcolumn.In
MIN(orcol_name)MAX(, wherecol_name)col_namerefers to aBIGINTcolumn.When using operators (
+,-,*, and so on) where both operands are integers.
You can always store an exact integer value in a
BIGINTcolumn by storing it using a string. In this case, MySQL performs a string-to-number conversion that involves no intermediate double-precision representation.The
-,+, and*operators useBIGINTarithmetic when both operands are integer values. This means that if you multiply two big integers (or results from functions that return integers), you may get unexpected results when the result is larger than9223372036854775807.
DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL]A packed“exact” fixed-point number.
Mis the total number of digits (the precision) andDis the number of digits after the decimal point (the scale). The decimal point and (for negative numbers) the-sign are not counted inM. IfDis 0, values have no decimal point or fractional part. The maximum number of digits (M) forDECIMALis 65. The maximum number of supported decimals (D) is 30. IfDis omitted, the default is 0. IfMis omitted, the default is 10. (There is also a limit on how long the text ofDECIMALliterals can be; seeSection 14.24.3, “Expression Handling”.)UNSIGNED, if specified, disallows negative values. As of MySQL 8.0.17, theUNSIGNEDattribute is deprecated for columns of typeDECIMAL(and any synonyms); you should expect support for it to be removed in a future version of MySQL. Consider using a simpleCHECKconstraint instead for such columns.All basic calculations (
+, -, *, /) withDECIMALcolumns are done with a precision of 65 digits.DEC[(,M[,D])] [UNSIGNED] [ZEROFILL]NUMERIC[(,M[,D])] [UNSIGNED] [ZEROFILL]FIXED[(M[,D])] [UNSIGNED] [ZEROFILL]These types are synonyms for
DECIMAL. TheFIXEDsynonym is available for compatibility with other database systems.FLOAT[(M,D)] [UNSIGNED] [ZEROFILL]A small (single-precision) floating-point number. Permissible values are
-3.402823466E+38to-1.175494351E-38,0, and1.175494351E-38to3.402823466E+38. These are the theoretical limits, based on the IEEE standard. The actual range might be slightly smaller depending on your hardware or operating system.Mis the total number of digits andDis the number of digits following the decimal point. IfMandDare omitted, values are stored to the limits permitted by the hardware. A single-precision floating-point number is accurate to approximately 7 decimal places.FLOAT(is a nonstandard MySQL extension. As of MySQL 8.0.17, this syntax is deprecated, and you should expect support for it to be removed in a future version of MySQL.M,D)UNSIGNED, if specified, disallows negative values. As of MySQL 8.0.17, theUNSIGNEDattribute is deprecated for columns of typeFLOAT(and any synonyms) and you should expect support for it to be removed in a future version of MySQL. Consider using a simpleCHECKconstraint instead for such columns.Using
FLOATmight give you some unexpected problems because all calculations in MySQL are done with double precision. SeeSection B.3.4.7, “Solving Problems with No Matching Rows”.FLOAT(p) [UNSIGNED] [ZEROFILL]A floating-point number.
prepresents the precision in bits, but MySQL uses this value only to determine whether to useFLOATorDOUBLEfor the resulting data type. Ifpis from 0 to 24, the data type becomesFLOATwith noMorDvalues. Ifpis from 25 to 53, the data type becomesDOUBLEwith noMorDvalues. The range of the resulting column is the same as for the single-precisionFLOATor double-precisionDOUBLEdata types described earlier in this section.UNSIGNED, if specified, disallows negative values. As of MySQL 8.0.17, theUNSIGNEDattribute is deprecated for columns of typeFLOAT(and any synonyms) and you should expect support for it to be removed in a future version of MySQL. Consider using a simpleCHECKconstraint instead for such columns.FLOAT(syntax is provided for ODBC compatibility.p)DOUBLE[(M,D)] [UNSIGNED] [ZEROFILL]A normal-size (double-precision) floating-point number. Permissible values are
-1.7976931348623157E+308to-2.2250738585072014E-308,0, and2.2250738585072014E-308to1.7976931348623157E+308. These are the theoretical limits, based on the IEEE standard. The actual range might be slightly smaller depending on your hardware or operating system.Mis the total number of digits andDis the number of digits following the decimal point. IfMandDare omitted, values are stored to the limits permitted by the hardware. A double-precision floating-point number is accurate to approximately 15 decimal places.DOUBLE(is a nonstandard MySQL extension. As of MySQL 8.0.17, this syntax is deprecated and you should expect support for it to be removed in a future version of MySQL.M,D)UNSIGNED, if specified, disallows negative values. As of MySQL 8.0.17, theUNSIGNEDattribute is deprecated for columns of typeDOUBLE(and any synonyms) and you should expect support for it to be removed in a future version of MySQL. Consider using a simpleCHECKconstraint instead for such columns.DOUBLE PRECISION[(,M,D)] [UNSIGNED] [ZEROFILL]REAL[(M,D)] [UNSIGNED] [ZEROFILL]These types are synonyms for
DOUBLE. Exception: If theREAL_AS_FLOATSQL mode is enabled,REALis a synonym forFLOATrather thanDOUBLE.
PDF (A4) - 43.4Mb
Man Pages (TGZ) - 297.2Kb
Man Pages (Zip) - 402.4Kb
Info (Gzip) - 4.3Mb
Info (Zip) - 4.3Mb
MySQL Globalization
MySQL Information Schema
MySQL Installation Guide
Security in MySQL
Starting and Stopping MySQL
MySQL and Linux/Unix
MySQL and Windows
MySQL and macOS
MySQL and Solaris
Building MySQL from Source
MySQL Restrictions and Limitations
MySQL Partitioning
MySQL Tutorial
MySQL Performance Schema
MySQL Replication
Using the MySQL Yum Repository
MySQL NDB Cluster 8.0