create table jj
(
id int not null primary key auto_increment,
name varchar(20) not null,
email varchar(20) ,
title varchar(50) not null,
content text,
time_insert datetime default 'NOW()'
);
(
id int not null primary key auto_increment,
name varchar(20) not null,
email varchar(20) ,
title varchar(50) not null,
content text,
time_insert datetime default 'NOW()'
);
(
id int not null primary key auto_increment,
name varchar(20) not null,
email varchar(20) ,
title varchar(50) not null,
content text,
time_insert datetime default 'NOW()'
);
可以通过,但不起作用,主要是mysql目录还不支持以函数值做为默认值.
输错了,重贴
(
id int not null primary key auto_increment,
name varchar(20) not null,
email varchar(20) ,
title varchar(50) not null,
content text,
time_insert datetime default 'NOW()'
);
可以通过,但不起作用,主要是mysql目前还不支持以函数值做为默认值,只能是在插入数据时再赋值了.
mysql can not support the function
I quote mysql manual document in here:
Default values must be constants. This means, for example, that you cannot set the default for a date column to be the value of a function such as NOW() or CURRENT_DATE.
For date and time types other than TIMESTAMP, the default is the appropriate zero value for the type. For the first TIMESTAMP column in a table, the default value is the current date and time.
TIMESTAMP(14) YYYYMMDDHHMMSS
TIMESTAMP(12) YYMMDDHHMMSS
TIMESTAMP(10) YYMMDDHHMM
TIMESTAMP(8) YYYYMMDD
TIMESTAMP(6) YYMMDD
TIMESTAMP(4) YYMM
TIMESTAMP(2) YY
它会自动地用当前的日期和时间标记你的INSERT或UPDATE的操作。如果一张表中有多个TIMESTAMP列,只有第一个自动更新。在下列情况下MySQL会自动更新第一个TIMESTAMP列为当前系统时间1、当一个INSERT、UPDATE或LOAD DATA INFILE语句中没有明确地指定其值时。 (注意一个UPDATE设置一个列为它已经有的值,这将不引起TIMESTAMP列被更新,因为如果你设置一个列为它当前的值,MySQL为了效率而忽略更改。看附例) 2、你明确地设定TIMESTAMP列为NULL. 3、除第一个以外的TIMESTAMP列也可以设置到当前的日期和时间,只要将列设为NULL,或NOW()。例:CREATE TABLE catv.call (
callintime timestamp(14) ,
calldh varchar(10) DEFAULT '',
callnm varchar(10) DEFAULT '',
calldq varchar(20) NOT NULL DEFAULT '' ,
callinnum varchar(14) DEFAULT '',
callinvoice varchar(28) DEFAULT '',
recallnum varchar(14) DEFAULT '',
pass enum('True','False') NOT NULL DEFAULT 'False' ,
KEY callinnum (callinnum),
KEY callintime (callintime)
)UPDATE call SET callintime=callintime,pass="True" 上一条指令会将表中所有的记录 pass 字段设为 True 而其它的字段值均不会改变!