像这样的问题很多,但我在其中找不到答案。
你能告诉我这里怎么了吗?这个脚本是由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;
给定的错误是
错误代码:1064。sql语法有错误;检查手册
与mariadb服务器版本相对应,以便使用near'constraint的正确语法 fk_Account_Owner
外键( OwnerId
)
第7行引用“myd”
2条答案
按热度按时间y1aodyip1#
在mysql workbench中:
去:
编辑>首选项>建模>mysql。
然后,将“default target mysql version”设置为5.7
从https://stackoverflow.com/a/52785302/2625955
nimxete22#
又一个需要摆脱这个词的例子
VISIBLE
.