Column Types
MySQL supports a number of column types, which may be grouped into three categories: numeric types, date and time types, and string (character) types. This section first gives an overview of the types available and summarises the storage requirements for each column type, then provides a more detailed description of the properties of the types in each category. The overview is intentionally brief. The more detailed descriptions should be consulted for additional information about particular column types, such as the allowable formats in which you can specify values.
The column types supported by MySQL are listed next. The following code letters are used in the descriptions:
- M
Indicates the maximum display size. The maximum legal display size is 255.
- D
Applies to floating-point types and indicates the number of digits following the decimal point. The maximum possible value is 30, but should be no greater than M-2.
Square brackets ([ and ]) indicate parts of type specifiers
that are optional.
Note that if you specify ZEROFILL for a column, MySQL will automatically add the UNSIGNED attribute to the column.
Warning: you should be aware that when you use subtraction between integer values where one is of type UNSIGNED, the result will be unsigned! See Section 6.3.5.
- TINYINT[(M)] [UNSIGNED] [ZEROFILL]
A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255.
- BIT , BOOL
These are synonyms for TINYINT(1).
- SMALLINT[(M)] [UNSIGNED] [ZEROFILL]
A small ...