mysql中有没有时间的默认值,就像sql server中的getdate()一样时间列如果不写时间的话,自动取服务器当前时间,不用写入
比如表msg如下
id integer auto increment 主键
content varchar(45)
senddate datetime写入insert into msg (content) values ('123')主键id 自动增长不用管
content写入了值 '123'
senddate自动就是当前的时间任何回答说自己取当前时间来写入的不要回复
比如表msg如下
id integer auto increment 主键
content varchar(45)
senddate datetime写入insert into msg (content) values ('123')主键id 自动增长不用管
content写入了值 '123'
senddate自动就是当前的时间任何回答说自己取当前时间来写入的不要回复
create table gg(
id integer auto_increment primary key,
content varchar(45),
senddate TIMESTAMP default now())
CURRENT_DATE() mysql> SELECT CURDATE();
-> '1997-12-15'NOW()
mysql> SELECT NOW();
-> '1997-12-15 23:50:26'
id INTEGER AUTO_INCREMENT PRIMARY KEY,
content VARCHAR(45),
senddate TIMESTAMP DEFAULT NOW()
) ;
可以这么写:create table msg
(
id integer not null auto increment primary key,
content varchar(45) not null,
senddate timestamp not null default current_timestamp
);
可以这么写:create table msg
(
id integer not null auto_increment primary key,
content varchar(45) not null,
senddate timestamp not null default current_timestamp
);
暂时,楼主只能在攒sql的时候,注意一下,用程序解决吧。