Data Types

Common data types in MySQL:

Data TypesUsage

INT

integers

DOUBLE

decimals

VARCHAR

string (less than 255 chars)

TEXT

string (more than 255 chars)

DATETIME

date and time

DATE

date only

In MySQL, DATETIME and DATE must be quoted using single quotes or double quotes. The format must be YYYY-MM-DD and HH:MM:SS. For example, we create a new table t_datetime:

CREATE TABLE t_datetime (a DATE);

Insert a date:

INSERT INTO t_datetime (a) VALUES('2022-02-22 22:22:22');

Last updated