日期/时间类型:
日期类型 date型,存储年月日。建一个时间表,存放李小欣同学的生日。
create table test4( stat varchar(20) not null default '', birth date not null default '0000-00-00')engine myisam charset utf8;
时间类型:time 如,每天签到,记录签到时间
日期时间类型:datetime 日期时间类型输入格式 yyyy-mm-dd HH:ii:ss
比如事件登录。//此处只是为了练习,真正精确到秒,用时间戳来记录。
create table test5( sanme varchar(20) not null default '', logintime datetime not null default '0000-00-00 00:00:00' )engine myisam charset utf8;
Timestamp 一个比较有意思的列,表示自动取出当前的时间。
create table test7(
-> ts timestamp default CURRENT_TIMESTAMP
-> id,int
-> )engine myisam charset utf8;
类型:year 只占一个字节,最多存256种变化
year类型还可以简写成两位,不推荐这么使用