首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

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

2012-07-15 
mysql 时间列自动插入当前日期时间用current_timestamp,不过这个默认值只用在timestamp的列,对datetime列

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

用current_timestamp,不过这个默认值只用在timestamp的列,对datetime列无效

例子:

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


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

?

例子:

insert into TB_IOT_SERVERCHILD(ParentID,ChildName,StartPath,logPath,Remark ,isStop ,isVisible,CreateTime) values(1,'子服务gggggggg','','','',0,0,current_timestamp)

热点排行