我正在尝试创建一些表格并用虚拟数据填充它们,我遇到了这个问题,这让我头疼我的脑袋,因为我不理解它。
以下是表格:
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时,我收到以下错误:
错误1064(42000):您的SQL语法有错误;检查 手册,对应右边的MySQL服务器版本 在'time,VEHICLE_veh_ID,DRIVER_dr_ID)VALUES附近使用的语法(01, '2016-02-06','09:30:00',03,05')第1行
我使用的是与之前表格相同的插入模式,其值与其对应的类型相匹配。我一遍又一遍地经历它,我看不出我做错了什么。任何帮助/建议?
答案 0 :(得分:1)
del time
应该是一个字。你写了#34; del_time"当你创建表时。