gpt4 book ai didi

mysql - 带有外键的 MariaDB 表创建错误

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

类似的问题有很多,但我无法从中找到答案。

你能告诉我这里有什么问题吗?该脚本是由 mysql Workbench 创建的,但它不排除答案

-- MySQL Script generated by MySQL Workbench
-- Mon Nov 26 14:14:46 2018
-- Model: New Model Version: 1.0
-- 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 mydb
-- -----------------------------------------------------

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

-- -----------------------------------------------------
-- Table `mydb`.`Owner`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Owner` ;

CREATE TABLE IF NOT EXISTS `mydb`.`Owner` (
`OwnerId` CHAR(36) NOT NULL,
`Name` NVARCHAR(60) NOT NULL,
`DateOfBirth` DATE NOT NULL,
`Adress` NVARCHAR(100) NOT NULL,
PRIMARY KEY (`OwnerId`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`Account`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Account` ;

CREATE TABLE IF NOT EXISTS `mydb`.`Account` (
`AccountId` CHAR(36) NOT NULL,
`DateCreated` DATE NOT NULL,
`AccountType` VARCHAR(45) NOT NULL,
`OwnerId` CHAR(36) NULL,
PRIMARY KEY (`AccountId`),
INDEX `fk_Account_Owner_idx` (`OwnerId` ASC) VISIBLE,
CONSTRAINT `fk_Account_Owner`
FOREIGN KEY (`OwnerId`)
REFERENCES `mydb`.`Owner` (`OwnerId`)
ON DELETE RESTRICT
ON UPDATE CASCADE)
ENGINE = InnoDB;


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

给定的错误是

Error Code: 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_Account_Owner FOREIGN KEY (OwnerId)
REFERENCES `myd' at line 7

最佳答案

又一个需要去掉单词 VISIBLE 的例子。

关于mysql - 带有外键的 MariaDB 表创建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53480613/

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