您好!我不明白有什么问题?
CREATE TABLE expenses(
num INT,
paydate DATE DEFAULT DATE(),
receiver INT NOT NULL DEFAULT 1,
value DEC(10,2) NOT NULL,
PRIMARY KEY(num)
);
我有一个问题:
ERROR 1064(42000):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 '(), receiver INT NOT NULL DEFAULT 1, value DEC(10,2) NOT NULL, PRIMARY KEY(num))' at line 4
最佳答案
不幸的是,MySQL 不允许您仅默认日期。您需要默认一个datetime
:
CREATE TABLE expenses (
num INT,
paydate datetime DEFAULT now(),
receiver INT NOT NULL DEFAULT 1,
value DEC(10,2) NOT NULL,
PRIMARY KEY (num)
);
Here是一个 SQL fiddle 。
关于mysql。语法错误 1064(42000),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46389415/