2019独角兽企业重金招聘Python工程师标准>>>
`date:年月日
datetime:年月日时分秒,保存确定的时间点的时候,存储形式yyyy-mm-dd hh:MM-dd,暂用8个字节
timestamp:时间从.存储时是整形数字,表现形式是yyyy-mm-dd hh:MM-dd,暂用4个字节,取值范围,1970-01-01 00:00:00到2038
year:1个字节 1901-2155,可以用0000表示默认值,如果输入两位'00-69'表示'2000-2069',如果输入'70-99'表示'1970-1999'
----------------------------------------
针对year类型
create table history(
title VARCHAR(20) not null DEFAULT '',
years YEAR(4)
)
输入:00或69或70或99
mysql> insert into history VALUES ('00','00'),('69','69'),('70','70'),('99','99');
Query OK, 4 rows affected (0.08 sec)
mysql> select * from history;
+-------+-------+
| title | years |
+-------+-------+
| 00 | 2000 |
| 69 | 2069 |
| 70 | 1970 |
| 99 | 1999 |
+-------+-------+
4 rows in set (0.00 sec)
为了便于理解,输入的时候输入4位范围内的数字
mysql> insert into history values ('minyear','1901'),('maxyear','2155');
Query OK, 2 rows affected (0.03 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> select * from history;
+---------+-------+
| title | years |
+---------+-------+
| 00 | 2000 |
| 69 | 2069 |
| 70 | 1970 |
| 99 | 1999 |
| minyear | 1901 |
| maxyear | 2155 |
+---------+-------+
6 rows in set (0.00 sec)
--------------------------------------`