Numeric Types
834
•
ENUM('value1','value2',...) [CHARACTER SET charset_name] [COLLATE
collation_name]
An enumeration. A string object that can have only one value, chosen from the list of values
'value1'
,
'value2'
,
...
,
NULL
or the special
''
error value.
ENUM
values are represented
internally as integers.
An
ENUM
column can have a maximum of 65,535 distinct elements. (The practical limit is less than
3000.) A table can have no more than 255 unique element list definitions among its
ENUM
and
SET
columns considered as a group. For more information on these limits, see
Section E.7.5, “Limits
Imposed by
.frm
File Structure”
.
•
SET('value1','value2',...) [CHARACTER SET charset_name] [COLLATE
collation_name]
A set. A string object that can have zero or more values, each of which must be chosen from the list
of values
'value1'
,
'value2'
,
...
SET
values are represented internally as integers.
A
SET
column can have a maximum of 64 distinct members. A table can have no more than 255
unique element list definitions among its
ENUM
and
SET
columns considered as a group. For more
information on this limit, see
Section E.7.5, “Limits Imposed by
.frm
File Structure”
.
11.1.4. 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
[539]
SQL mode is enabled.
As of MySQL 5.0.3, a
BIT
data type is available for storing bit-field values. (Before 5.0.3, MySQL
interprets
BIT
as
TINYINT(1)
.) In MySQL 5.0.3,
BIT
is supported only for
MyISAM
. MySQL 5.0.5
extends
BIT
support to
MEMORY
,
InnoDB
,
BDB
, and
NDBCLUSTER
.
For information about how MySQL handles assignment of out-of-range values to columns and overflow
during expression evaluation, see
Section 11.1.4.6, “Out-of-Range and Overflow Handling”
.
For information about numeric type storage requirements, see
Section 11.2, “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”
.
11.1.4.1. Integer Types (Exact Value) -
INTEGER
,
INT
,
SMALLINT
,
TINYINT
,
MEDIUMINT
,
BIGINT
MySQL supports the SQL standard integer types
INTEGER
(or
INT
) and
SMALLINT
. As an extension
to the standard, MySQL also supports the integer types
TINYINT
,
MEDIUMINT
, and
BIGINT
. The
following table shows the required storage and range for each integer type.
Type
Storage
Minimum Value
Maximum Value
(Bytes)
(Signed/Unsigned)
Signed/Unsigned)
TINYINT
1
-128
127
0
255
SMALLINT
2
-32768
32767
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...