There are three main categories of datatypes that MySQL allows. They are:
All the data types supported in MySQL fall into one of these categories. Given below are the different types of data types with their range of values.
Datatype | Type of use | Range of Values |
---|---|---|
INT |
Regular number | signed: -2147483648 to 2147483647 unsigned: 4294967295 |
TINYINT |
Very small value numbers | signed: -128 to 127 unsigned: 0 to 255 |
SMALLINT |
Small signed or unsigned int | signed: -32768 to 32767 unsigned: 0 to 65535 |
MEDIUMINT |
Medium signed or unsigned int | signed: -8388608 to 8388607 unsigned: 0 to 16777215 |
BIGINT |
Large value signed or unsigned int | signed:-9223372036854775808 to 9223372036854775807 unsigned: 0 to 18446744073709551615 |
FLOAT(M,D) |
A signed floating-point number | The default precision is 10,2 and can go up to 24 places |
DOUBLE(M,D) |
A double-precision floating-point number | the default precision is 16,4 and can go up to 53 places. |
DECIMAL(M,D) |
An unpacked floating-point number | the M and D are required. These are always signed. |
Datatype | Type of use | Range of Values |
---|---|---|
DATE |
A date in YYYY-MM-DD format | 1000-01-01 and 9999-12-31 |
DATETIME |
YYYY-MM-DD HH:MM:SS format | 1000-01-01 00:00:00 and 9999-12-31 23:59:59 |
TIMESTAMP |
YYYYMMDDHHMMSS | 1970-01-01 to some time in 2037 |
TIME |
time in HH:MM:SS | |
YEAR(M) |
a year in 2-digit or 4-digit | Between 1970 and 2069 |
Datatype | Type of use | Range of Values |
---|---|---|
CHAR(M) |
A fixed-length string | 1 and 255 |
VARCHAR(M) |
A variable-length string with the maximum size defined by M | 1 and 255 |
BLOB OR TEXT |
Any kind of binary data. | Max 65535 characters |
TINYBLOB or TINYTEXT |
Small binary data | Max 255 characters |
MEDIUMBLOB OR MEDIUMTEXT |
Medium-sized binary data | Max 16777215 characters |
LONGBLOB OR LONTEXT |
A blob or a text column | Max 4294967295 characters. |
ENUM |
List | List up to 65535 values in an ENUM list |