mysql 时间列自动插入当前日期时间

来源:互联网 发布:网页淘宝卡券包在哪里 编辑:程序博客网 时间:2024/05/18 03:13
用current_timestamp,不过这个默认值只用在timestamp的列,对datetime列无效

例子:
create table default_time (
  id 
int not null primary key auto_increment,
  name 
varchar(20default 'chenlb',
  my_time 
timestamp default current_timestamp
);

注意:一个表只能有一个timestamp列的默认值为当前日期时间。 
0 0