随笔-153  评论-235  文章-19  trackbacks-0
     用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列的默认值为当前日期时间。
posted on 2007-07-08 21:29 流浪汗 阅读(6101) 评论(2)  编辑  收藏 所属分类: MySQL

评论:
# re: mysql 时间列自动插入当前日期时间 2008-07-28 10:55 | 时间太快了
我一般都直接写一个给定的默认值。如"2008-01-01".否则我将会用程序的给出当前的系统日期值。再传进去。  回复  更多评论
  
# re: mysql 时间列自动插入当前日期时间 2012-03-12 15:59 | whx
预设值填入CURRENT_TIMESTAMP  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: