Numbers, strings, date.
Character data:
char(20) /* fixed-length, uses spaces at right */
varchar(20) /* variable-length */
tinytext 255
text 65,535
mediumtext 16,777,215
longtext 4,294,967,295
/*
text will be truncated if length exceeds, spaces will not be removed.
in sorting and searching first 1024 chars will be used by default.
*/Numeric data:
Tyte | Signed range | Unsigned range |
tinyint | −128 to 127 | 0 to 255 |
smallint | −32,768 to 32,767 | 0 to 65,535 |
mediumint | −8,388,608 to 8,388,607 | 0 to 16,777,215 |
int | −2,147,483,648 to 2,147,483,647 | 0 to 4,294,967,295 |
bigin | −2^63 to 2^63 - 1 | 0 to 2^64 - 1 |
float(ps) | −3.402823466E+38 to −1.175494351E-38 | 1.175494351E-38 to 3.402823466E+38 |
double(ps)
precision, scale | −1.7976931348623157E+308 to −2.2250738585072014E-308 | 2.2250738585072014E-308 to 1.7976931348623157E+308 |
Ex: float(4,2) will store a total of four digits, two to the left of the decimal and two to the right of the decimal. Ex: 27.44 and 8.19
Temporal data (Date):
Type | Default format | Allowable values |
date | YYYY-MM-DD | 1000-01-01 to 9999-12-31 |
datetime | YYYY-MM-DD HH:MI:SS | 1000-01-01 00:00:00.000000
to 9999-12-31 23:59:59.999999 |
timestamp | YYYY-MM-DD HH:MI:SS | 1970-01-01 00:00:00.000000 to 2038-01-18 22:14:07.999999 |
year | YYYY | 1901 to 2155 |
time | HHH:MI:SS | −838:59:59.000000
to 838:59:59.000000 |