【高手进】mySQL运行问题 1064错误
我写了一个图书管理系统。其中由ER图生成数据库的部分出了问题。就这一个问题,望各位大神耐心看一看,解决了就Ok了错误类型和解释如下:ExecutingSQLscripti...
我写了一个图书管理系统。其中由ER图生成数据库的部分出了问题。就这一个问题,望各位大神耐心看一看,解决了就Ok了
错误类型和解释如下:
Executing SQL script in server
ERROR: Error 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 ') //据说1064类错误是语法错误或是关键字重复
REFERENCES `mydb`.`Book` () //这个Book是一个实体
ON DELETE NO ACTION
ON UPDATE NO ACTIO' at line 8 //这里的Action我的代码是全的,但是不知道为啥到错误解释里 面 就 少了最后的尾巴
SQL Code: //以下是另一个实体:BookBorrow 上面的出错代码就来自这个实体的定义语句
CREATE TABLE IF NOT EXISTS `mydb`.`BookBorrow` (
`readersID` VARCHAR(10) NOT NULL,
`bookID` VARCHAR(10) NOT NULL,
`borrowDate` DATETIME NULL,
`ShouldReturnDate` DATETIME NULL,
PRIMARY KEY (`readersID`, `bookID`),
CONSTRAINT `bookID` //这里是把bookID设为外键,与Book实体相联
FOREIGN KEY ()
REFERENCES `mydb`.`Book` () //这里就是报错的地方
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `readersID`
FOREIGN KEY ()
REFERENCES `mydb`.`Readers` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
SQL script execution finished: statements: 15 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch 展开
错误类型和解释如下:
Executing SQL script in server
ERROR: Error 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 ') //据说1064类错误是语法错误或是关键字重复
REFERENCES `mydb`.`Book` () //这个Book是一个实体
ON DELETE NO ACTION
ON UPDATE NO ACTIO' at line 8 //这里的Action我的代码是全的,但是不知道为啥到错误解释里 面 就 少了最后的尾巴
SQL Code: //以下是另一个实体:BookBorrow 上面的出错代码就来自这个实体的定义语句
CREATE TABLE IF NOT EXISTS `mydb`.`BookBorrow` (
`readersID` VARCHAR(10) NOT NULL,
`bookID` VARCHAR(10) NOT NULL,
`borrowDate` DATETIME NULL,
`ShouldReturnDate` DATETIME NULL,
PRIMARY KEY (`readersID`, `bookID`),
CONSTRAINT `bookID` //这里是把bookID设为外键,与Book实体相联
FOREIGN KEY ()
REFERENCES `mydb`.`Book` () //这里就是报错的地方
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `readersID`
FOREIGN KEY ()
REFERENCES `mydb`.`Readers` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
SQL script execution finished: statements: 15 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询