1、建表的时候添加自动更新字段:
create table `test_table` (
`id` int(11) not null auto_increment,
`last_update_time` timestamp not null default current_timestamp on update current_timestamp,
primary key (`id`)
) engine=innodb auto_increment=1 default charset=utf8
2、建表后,修改字段为自动更新:
alter table test_table change last_update_time last_update_time timestamp not null
default current_timestamp on update current_timestamp;