gpt4 book ai didi

mysql - MySQL Workbench 中的正向工程输出错误 1064

转载 作者:行者123 更新时间:2023-11-29 16:53:51 24 4
gpt4 key购买 nike

这是 MySQL Workbench 在正向工程时创建的脚本:

-- MySQL Workbench Forward Engineering

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

-- -----------------------------------------------------
-- Schema DialogueFlowDB
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema DialogueFlowDB
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `DialogueFlowDB` DEFAULT CHARACTER SET utf8 ;
USE `DialogueFlowDB` ;

-- -----------------------------------------------------
-- Table `DialogueFlowDB`.`Status`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DialogueFlowDB`.`Status` (
`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`Status` CHAR(255) NOT NULL,
PRIMARY KEY (`ID`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `DialogueFlowDB`.`MultiStep_Dialogues`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DialogueFlowDB`.`MultiStep_Dialogues` (
`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`MultiStep_Dialogue` CHAR(255) NOT NULL,
`Data_Items` VARCHAR(1000) NULL,
`Nodes` VARCHAR(1000) NULL,
`Node_Links` VARCHAR(1000) NULL,
`Comments` VARCHAR(1000) NULL,
`Status` INT UNSIGNED NOT NULL,
`Issue` INT NOT NULL,
`LO_Name` CHAR(255) NULL,
`LO_Description` CHAR(255) NULL,
`LO_Condition` VARCHAR(1000) NULL,
`LO_Variables` VARCHAR(1000) NULL,
`LO_List` INT NULL,
PRIMARY KEY (`ID`),
INDEX `fk_MultiStep_Dialogues_Status1_idx` (`Status` ASC) VISIBLE,
CONSTRAINT `fk_MultiStep_Dialogues_Status1`
FOREIGN KEY (`Status`)
REFERENCES `DialogueFlowDB`.`Status` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `DialogueFlowDB`.`Node_Types`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DialogueFlowDB`.`Node_Types` (
`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`Node_Type` CHAR(255) NOT NULL,
PRIMARY KEY (`ID`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `DialogueFlowDB`.`Variables`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DialogueFlowDB`.`Variables` (
`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`Variable` CHAR(255) NOT NULL,
`Variable_ID` CHAR(255) NOT NULL,
`System_Variable` CHAR(255) NULL,
`Values_per_Item` ENUM('Single', 'Multiple') NOT NULL DEFAULT 'Single',
`MultiStep_Dialogue` INT UNSIGNED NOT NULL,
`Input_Values` VARCHAR(1000) NULL,
`Comments` VARCHAR(1000) NULL,
PRIMARY KEY (`ID`),
INDEX `fk_Variables_MultiStep_Dialogues1_idx` (`MultiStep_Dialogue` ASC) VISIBLE,
CONSTRAINT `fk_Variables_MultiStep_Dialogues1`
FOREIGN KEY (`MultiStep_Dialogue`)
REFERENCES `DialogueFlowDB`.`MultiStep_Dialogues` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `DialogueFlowDB`.`Nodes`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DialogueFlowDB`.`Nodes` (
`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`Node` CHAR(255) NOT NULL,
`Node_ID` CHAR(255) NOT NULL,
`Node_Sequence` ENUM('End', 'Middle', 'Start') NOT NULL,
`Node_Type` INT UNSIGNED NOT NULL,
`XPosition` INT NOT NULL DEFAULT 0,
`YPosition` INT NOT NULL DEFAULT 0,
`Answer` VARCHAR(1000) NOT NULL,
`Data_Item` INT UNSIGNED NULL,
`Status` INT UNSIGNED NOT NULL DEFAULT 'Created',
`MultiStep_Dialogue` INT UNSIGNED NOT NULL,
`Comments` VARCHAR(1000) NULL,
`Previous_Node_Links` VARCHAR(1000) NULL,
`Next_Node_Link` VARCHAR(100) NULL,
PRIMARY KEY (`ID`),
INDEX `fk_Nodes_MultiStep_Dialogues_idx` (`MultiStep_Dialogue` ASC) VISIBLE,
INDEX `fk_Nodes_Node_Types1_idx` (`Node_Type` ASC) VISIBLE,
INDEX `fk_Nodes_Variables1_idx` (`Data_Item` ASC) VISIBLE,
INDEX `fk_Nodes_Status1_idx` (`Status` ASC) VISIBLE,
CONSTRAINT `fk_Nodes_MultiStep_Dialogues`
FOREIGN KEY (`MultiStep_Dialogue`)
REFERENCES `DialogueFlowDB`.`MultiStep_Dialogues` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Nodes_Node_Types1`
FOREIGN KEY (`Node_Type`)
REFERENCES `DialogueFlowDB`.`Node_Types` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Nodes_Status1`
FOREIGN KEY (`Status`)
REFERENCES `DialogueFlowDB`.`Status` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Nodes_Variables1`
FOREIGN KEY (`Data_Item`)
REFERENCES `DialogueFlowDB`.`Variables` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `DialogueFlowDB`.`Node_Links`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DialogueFlowDB`.`Node_Links` (
`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`Node_Link` CHAR(255) NOT NULL,
`MultiStep_Dialogue` INT UNSIGNED NOT NULL,
`From_Node` INT UNSIGNED NOT NULL,
`To_Node` INT UNSIGNED NOT NULL,
`Status` INT UNSIGNED NOT NULL,
`Comments` VARCHAR(1000) NULL,
PRIMARY KEY (`ID`),
INDEX `fk_Node_Links_Nodes1_idx` (`From_Node` ASC) VISIBLE,
INDEX `fk_Node_Links_MultiStep_Dialogues1_idx` (`MultiStep_Dialogue` ASC) VISIBLE,
INDEX `fk_Node_Links_Nodes2_idx` (`To_Node` ASC) VISIBLE,
INDEX `fk_Node_Links_Status1_idx` (`Status` ASC) VISIBLE,
CONSTRAINT `fk_Node_Links_Nodes1`
FOREIGN KEY (`From_Node`)
REFERENCES `DialogueFlowDB`.`Nodes` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Node_Links_MultiStep_Dialogues1`
FOREIGN KEY (`MultiStep_Dialogue`)
REFERENCES `DialogueFlowDB`.`MultiStep_Dialogues` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Node_Links_Nodes2`
FOREIGN KEY (`To_Node`)
REFERENCES `DialogueFlowDB`.`Nodes` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Node_Links_Status1`
FOREIGN KEY (`Status`)
REFERENCES `DialogueFlowDB`.`Status` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

这是输出:

Executing SQL script in server
ERROR: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '
CONSTRAINT `fk_MultiStep_Dialogues_Status1`
FOREIGN KEY (`Status`)
RE' at line 19
SQL Code:
-- -----------------------------------------------------
-- Table `DialogueFlowDB`.`MultiStep_Dialogues`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `DialogueFlowDB`.`MultiStep_Dialogues` (
`ID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`MultiStep_Dialogue` CHAR(255) NOT NULL,
`Data_Items` VARCHAR(1000) NULL,
`Nodes` VARCHAR(1000) NULL,
`Node_Links` VARCHAR(1000) NULL,
`Comments` VARCHAR(1000) NULL,
`Status` INT UNSIGNED NOT NULL,
`Issue` INT NOT NULL,
`LO_Name` CHAR(255) NULL,
`LO_Description` CHAR(255) NULL,
`LO_Condition` VARCHAR(1000) NULL,
`LO_Variables` VARCHAR(1000) NULL,
`LO_List` INT NULL,
PRIMARY KEY (`ID`),
INDEX `fk_MultiStep_Dialogues_Status1_idx` (`Status` ASC) VISIBLE,
CONSTRAINT `fk_MultiStep_Dialogues_Status1`
FOREIGN KEY (`Status`)
REFERENCES `DialogueFlowDB`.`Status` (`ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB

SQL script execution finished: statements: 6 succeeded, 1 failed

Fetching back view definitions in final form.
Nothing to fetch

我在网上阅读,问题可能与外键有关(尽管我检查过,看起来不错......)或与 engine = InnoDB 声明有关。我尝试使用 this question 中的答案但它不起作用或者我不太明白答案(我交换了 ENGINE = InnoDB; 与 ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; )我还检查了我的 mysql 版本,我使用 10.1.35 -MariaDB 应该具有可用的不可见索引(如我链接的问题的另一个答案中提到的)。

我对 mySQL 没有任何经验,所以如果这是一个非常简单的问题,我很抱歉。感谢您的帮助:)

最佳答案

好吧,有两个不同的问题。 DialogueFlow 表中 Unsigned Int“Status”的默认值是“Created”(我从使用 ENUM 更改为使用外键,忘记删除旧的默认值),所以它是

Status INT UNSIGNED NOT NULL DEFAULT 'Created'

另一个问题似乎与索引有关。删除所有时:

INDEX fk_MultiStep_Dialogues_Status1_idx (Status ASC) VISIBLE

INDEX fk_Nodes_MultiStep_Dialogues_idx (MultiStep_Dialogue ASC) VISIBLE,

INDEX fk_Nodes_Node_Types1_idx (Node_Type ASC) VISIBLE,

等等,好像还可以。我不太明白为什么会发生这种情况,但现在我将删除外键上的索引并稍后修复它。

关于mysql - MySQL Workbench 中的正向工程输出错误 1064,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52679732/

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