0

我正在尝试创建一个带有时间戳字段的表,但收到此错误 ERROR 1064 (42000): You have an error in your SQL syntax; 检查与您的 MySQL 服务器版本相对应的手册,以在第 3 行的“DEFAULT TIMESTAMP NOT NULL, start_time TIMESTAMP NOT NULL, end_time TIME”附近使用正确的语法我试过 DEFAULT CURRENT_TIMESTAMP 但它没有用。如果有人可以帮助我,那就太好了,因为我尝试搜索问题但找不到任何东西。

CREATE TABLE appointment (
app_id int(5) NOT NULL AUTO_INCREMENT,
date_created DEFAULT CURRENT_TIMESTAMP NOT NULL,
start_time TIMESTAMP NOT NULL,
end_time TIMESTAMP NOT NULL,
client_id int(5),
price decmial(10,2),
cancelled tinyint(1),
treatment_id int(5) NOT NULL,
specialist_id int(5) NOT NULL,
PRIMARY KEY (client_id),
FOREIGN KEY (treatment_id) REFERENCES treatment(treatment_id),
FOREIGN KEY (client_id) REFERENCES client(client_id),
FOREIGN KEY (specialist_id) REFERENCES specialist(specialist_id)
) ENGINE=InnoDB;
4

1 回答 1

0

date_created没有类型!而非空字段需要一个默认值

CREATE TABLE appointment (
app_id int(5) NOT NULL AUTO_INCREMENT,
date_created TIMESTAMP  DEFAULT CURRENT_TIMESTAMP NOT NULL,
start_time TIMESTAMP DEFAULT CURRENT_TIMESTAMPNOT NULL,
end_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
client_id int(5),
price decmial(10,2),
cancelled tinyint(1),
treatment_id int(5) NOT NULL,
specialist_id int(5) NOT NULL,
PRIMARY KEY (client_id),
FOREIGN KEY (treatment_id) REFERENCES treatment(treatment_id),
FOREIGN KEY (client_id) REFERENCES client(client_id),
FOREIGN KEY (specialist_id) REFERENCES specialist(specialist_id)
) ENGINE=InnoDB;
于 2020-04-05T18:23:00.567 回答