我创建表test,有两个字段id,ctime;
CREATE TABLE test(
id INT PRIMARY KEY,
ctime DATETIME NOT NULL DEFAULT CURDATE()
);
错误码: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'curdate()
)' at line 3
ctime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
ctime date 跟上约束条件(比如非空或 是系统时间)ctime datetime 没意义 再者说了
mysql 1064错误
该错误一般出现在表名或者字段名设计过程中出现了mysql关键字导致的。
是你的函数问题,你可以换一个,用这个DEFAULT CURRENT_TIMESTAMP,或者now()。