Date type
If you want to use the date, it is usually represented by date.
It is usually expressed in datetime if it is to be used to denote a month or a day.
It is usually represented by time if it is used only to represent seconds and minutes.
Timestamp expression format: Yyyy-mm-dd HH:MM:SS.
If only the year is represented, it can be expressed in years. Date,datetime,time is commonly used in three species.
CREATE TABLE T (d date,t time,dt DATETIME)--Inserts the current date insert into T VALUES (now (), today (), today ());--View select * from T;
TIMESTAMP is also used to denote dates, which are associated with time zones (DateTime only reflects the local time zone at the time of insertion, while others in other time zones are bound to have errors in viewing data. )
CREATE TABLE T3 (d1 TIMESTAMP not NULL DEFAULT current_timestamp), INSERT into T3 VALUES (now ());
Finally, the date "2007-9-3 12:10:10" is inserted into the datetime column in a different format
CREATE TABLE T6 (dt DATETIME), insert into T6 values (' 2007-9-3 12:10:10 '), insert into T6 values (' 2007/9/3 12+10+10 '); insert into T6 values (' 20070903121010 '), INSERT into T6 values (20070903121010); SELECT * from T6;
MySQL Development Basic Series 3