gpt4 book ai didi

mysql - MYSQL 新增,INSERT INTO 'Table' 语法错误

转载 作者:行者123 更新时间:2023-11-29 11:44:18 26 4
gpt4 key购买 nike

我正在尝试创建一些表并用虚拟数据填充它们,但我遇到了这个问题,这让我摸不着头脑,因为我不明白它。

以下是表格:

CREATE TABLE `DRIVER` (
`dr_ID` INT NOT NULL,
`dr_title` VARCHAR(15) NOT NULL,
`dr_fname` VARCHAR(45) NOT NULL,
`dr_lname` VARCHAR(45) NOT NULL,
`dr_DOB` DATETIME NOT NULL,
`dr_licenceNo` VARCHAR(45) NOT NULL,
`dr_phone` VARCHAR(15) NOT NULL,
`dr_email` VARCHAR(45) NOT NULL,
PRIMARY KEY (`dr_ID`));

CREATE TABLE `VEHICLE` (
`veh_ID` INT NOT NULL,
`veh_reg` VARCHAR(15) NOT NULL,
`veh_make` VARCHAR(45) NOT NULL,
`veh_model` VARCHAR(45) NOT NULL,
`veh_mileage` INT NOT NULL,
`veh_MOTdate` DATETIME NOT NULL,
`veh_servicedate` DATETIME NOT NULL,
PRIMARY KEY (`veh_ID`));

CREATE TABLE `DELIVERY` (
`del_ID` VARCHAR(45) NOT NULL,
`del_date` DATETIME NOT NULL,
`del_time` DATETIME NOT NULL,
`VEHICLE_veh_ID` INT NOT NULL,
`DRIVER_dr_ID` INT NOT NULL,
INDEX `fk_VEHICLE_has_DRIVER_DRIVER1_idx` (`DRIVER_dr_ID` ASC),
INDEX `fk_VEHICLE_has_DRIVER_VEHICLE1_idx` (`VEHICLE_veh_ID` ASC),
PRIMARY KEY (`del_ID`),
CONSTRAINT `fk_VEHICLE_has_DRIVER_VEHICLE1`
FOREIGN KEY (`VEHICLE_veh_ID`)
REFERENCES `VEHICLE` (`veh_ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_VEHICLE_has_DRIVER_DRIVER1`
FOREIGN KEY (`DRIVER_dr_ID`)
REFERENCES `DRIVER` (`dr_ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION);

INSERT INTO DELIVERY(del_ID, del_date, del time, VEHICLE_veh_ID, DRIVER_dr_ID) VALUES
(01, '2016-02-06', '09:30:00', 03, 05),
(02, '2016-02-06', '09:30:00', 01, 02),
(03, '2016-02-07', '09:30:00', 02, 03),
(04, '2016-02-07', '09:30:00', 04, 01),
(05, '2016-02-07', '09:30:00', 10, 04),
(06, '2016-02-08', '09:30:00', 07, 01),
(07, '2016-02-08', '09:30:00', 08, 02),
(08, '2016-02-08', '09:30:00', 09, 03),
(09, '2016-02-08', '09:30:00', 02, 04),
(10, '2016-02-09', '09:30:00', 03, 05);

我将数据插入 DRIVER 和 VEHICLE 中,没有任何问题,但是当我尝试将数据插入 DELIVERY 中时,出现以下错误:

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 'time, VEHICLE_veh_ID, DRIVER_dr_ID) VALUES (01, '2016-02-06', '09:30:00', 03, 05') at line 1

我使用与之前的表相同的插入模式,并且值与其相应的类型匹配。我一遍又一遍地回顾它,但我看不出我做错了什么。有什么帮助/建议吗?

最佳答案

 del time

应该是一个词。您在创建表时写入了“del_time”。

关于mysql - MYSQL 新增,INSERT INTO 'Table' 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35221897/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com