DateTime types are used when you need to include values for both date and time information. MySQL retrieves and displays the datetime value in the ' yyyy-mm-dd HH:MM:SS ' format, supported by ' 1000-01-01 00:00:00 ' to ' 9999-12-31 23:59:59 '. ("support" means that although earlier values may work, there is no guarantee that they can.) )
The date type has no time part when you only need a date value. MySQL retrieves and displays date values in the ' YYYY-MM-DD ' format, supported by ' 1000-01-01 ' to ' 9999-12-31 '.
The timestamp column type provides a type that you can use to automatically mark an INSERT or update operation with the current date and time.
The time data type represents the times of the day. MySQL retrieves and displays the time value in "HH:MM:SS" format. The range of support is ' 00:00:00 ' to ' 23:59:59 '.
CREATE TABLE SQL
CREATE TABLE ' tb_test ' (
' id ' int () NOT NULL auto_increment,
' date1 ' timestamp not null DEFAULT ' 0000-00-00 00:0 0:00 ' on UPDATE current_tim
estamp,
' date2 ' date default null,
' date3 ' datetime default NULL,
' time ' Time DEFAULT NULL,
PRIMARY KEY (' id ')
);
Screenshot of Run Effect:
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/MySQL/