gpt4 book ai didi

mysql - mysql语法错误

转载 作者:行者123 更新时间:2023-11-29 05:45:33 25 4
gpt4 key购买 nike

在执行以下查询时,我收到一条错误消息,指出第 9 行附近的语法存在错误。因为我使用的是 mysql workbench,所以我真的无法弄清楚可能出了什么问题:

CREATE  TABLE IF NOT EXISTS `proquotes`.`thquotes` (

`idQuotes` INT NOT NULL AUTO_INCREMENT ,

`vAuthorID` VARCHAR(8) CHARACTER SET 'utf8' NOT NULL ,

`vAuthor` VARCHAR(45) CHARACTER SET 'utf8' NOT NULL ,

`cQuotes` MEDIUMTEXT CHARACTER SET 'utf8' NOT NULL ,

`cArabic` MEDIUMTEXT CHARACTER SET 'utf8' NOT NULL ,

`vReference` VARCHAR(100) CHARACTER SET 'utf8' NOT NULL ,

PRIMARY KEY (`idQuotes`) ,

INDEX `vAuthorID` () ,

CONSTRAINT `vAuthorID`

FOREIGN KEY ()

REFERENCES `proquotes`.`author_info` ()

ON DELETE NO ACTION

ON UPDATE NO ACTION)

DEFAULT CHARACTER SET = utf8;

表作者信息:

CREATE  TABLE IF NOT EXISTS `proquotes`.`author_info` (  

`vAuthorID` INT NOT NULL , `vAuthor` VARCHAR(45) CHARACTER

SET 'utf8' NOT NULL , `nQuotes` INT NOT NULL , PRIMARY KEY

(`vAuthorID`) , UNIQUE INDEX `vAuthorID_UNIQUE` (`vAuthorID`

ASC) )DEFAULT CHARACTER SET = utf8;

最佳答案

语法错误似乎是空括号:INDEX vAuthorID ()FOREIGN KEY ()REFERENCES proquotes.author_info ()。这些括号应该引用一个或多个表属性。

例如:

INDEX `vAuthorID` (`vAuthorID`) ,
CONSTRAINT `vAuthorID`
FOREIGN KEY (`vAuthorID`)
REFERENCES `proquotes`.`author_info` (`vAuthorID`)

REFERENCES 子句的最后一个括号应该引用 author_info 中的属性,而不是来自 thquotes。因此,您可能需要相应地更改 vAuthorID

关于mysql - mysql语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2609556/

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