Each and every database tables have some columns and rows. Each column contains some value and that value belongs to some data type. The data type of a column describes the data stored in that column.
String data types in MySQL
Some String data types in MySQL are shown in below table:
| Data type | Description |
|---|---|
| CHAR | A fixed-length non-binary string and the length can be anything from 0 to 255. |
| VARCHAR | A variable-length non-binary string and the length can be from 0 to 65535 |
| TINYTEXT | A very small-sized non-binary string. |
| TEXT | A small-sized non-binary string. |
| MEDIUMTEXT | A medium-sized non-binary string. |
| LONGTEXT | A long-sized non-binary string. |
| BINARY | Similar to CHAR but it stores binary strings. |
| VARBINARY | Similar to VARCHAR but it stores binary strings. |
| TINY BLOB | A very small BLOB (Binary Large Objects). |
| BLOB | A small-sized BLOB. |
| MEDIUMBLOB | A medium-sized BLOB. |
| LONGBLOB | A long BLOB. |
| ENUM | A string object with a value chosen from a list of values. |
| SET | A string object and can have 0 or more values chosen from a list of values. |
Numeric data types in MySQL
Numeric data types represent numbers like integer, floating-point, fixed-point, etc.
Some Numeric data types in MySQL are shown in below table:
| Data type | Description |
|---|---|
| BIT | A bit value. |
| TINYINT | A very small integer value. |
| SMALLINT | A small integer value having unsigned range from 0 to 65535 and signed range from -32768 to 32767. |
| MEDIUMINT | A medium-sized integer. Its unsigned range is from 0 to 16777215 and signed from -8388608 to 8388607. |
| INT | An integer ranging from 0 to 4294967295 or signed range is from -2147483648 to 2147483647. |
| BIGINT | A big integer value having an unsigned range from 0 to 264-1 or from -263 to 263-1. |
| DECIMAL | A fixed-point number. |
| FLOAT | A floating-point number. |
| DOUBLE | A double-precision floating point number. |
Date and Time Data Types
MySQL has data types for date and time and date and time together. Some of them are shown below:
| Data type | Description |
|---|---|
| TIME | Time in hh:mm:ss format. |
| DATE | A date in YYYY-MM-DD format. |
| DATETIME | It is a combination of date and time. Its format is YYYY-MM-DD hh:mm:ss |
| TIMESTAMP | A timestamp value in the format YYYY-MM-DD hh:mm:ss |
| YEAR | A four-digit year value in the format YYYY. |