在创建表时如果表中有一个字段类型为timestamp,则该字段默认的生成语句为:
create table `test` ( `id` int(11) default null, `ctime` timestamp not null default current_timestamp on update current_timestamp) engine=innodb default charset=gbk
如果有两个字段类型为timestamp,则生成语句为:
create table `test` ( `id` int(11) default null, `ctime` timestamp not null default current_timestamp on update current_timestamp, `utime` timestamp not null default '0000-00-00 00:00:00') engine=innodb default charset=gbk
timestamp设置默认值是default current_timestamp、timestamp设置随着表变化而自动更新是on update current_timestamp1、timestamp default current_timestamp on update current_timestamp
在创建新记录和修改现有记录的时候都对这个数据列刷新2、timestamp default current_timestamp
在创建新记录的时候把这个字段设置为当前时间,但以后修改时,不再刷新它3、timestamp on update current_timestamp
在创建新记录的时候把这个字段设置为0,以后修改时刷新它