gpt4 book ai didi

mysql - fk 引用上的未知数据类型

转载 作者:行者123 更新时间:2023-11-29 19:07:53 26 4
gpt4 key购买 nike

我正在尝试在我的 H2 数据库中运行此 mysql 命令。 DB设置为mysql模式。

-- -----------------------------------------------------
-- Table `users`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `users` (
`id` INT NOT NULL,
`username` VARCHAR(45) NOT NULL COMMENT ' ',
`email` VARCHAR(320) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `serverprojects`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `serverprojects` (
`id` INT NOT NULL,
`name` VARCHAR(100) NOT NULL,
`status` TINYINT(1) NULL,
`restorescript_relative_path` VARCHAR(255) NULL,
`backupscript_relative_path` VARCHAR(255) NULL,
`installscript_relative_path` VARCHAR(255) NULL,
`username` VARCHAR(100) NULL,
`password` VARCHAR(100) NULL,
`gradle_relative_path` VARCHAR(255) NULL,
`root_path` VARCHAR(1000) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `projects`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `projects` (
`id` INT NOT NULL,
`name` VARCHAR(100) NOT NULL,
`serverprojects_id` INT NOT NULL,
`users_id` INT NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_projects_serverprojects_idx` (`serverprojects_id` ASC),
INDEX `fk_projects_users1_idx` (`users_id` ASC),
CONSTRAINT `fk_projects_serverprojects`
FOREIGN KEY (`serverprojects_id`)
REFERENCES `serverprojects` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_projects_users1`
FOREIGN KEY (`users_id`)
REFERENCES `users` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;


SET FOREIGN_KEY_CHECKS=1;

这产生了以下错误输出

Unbekannter Datentyp: "FK_PROJECTS_SERVERPROJECTS_IDX"
Unknown data type: "FK_PROJECTS_SERVERPROJECTS_IDX"; SQL statement:
-- -----------------------------------------------------
-- Table `projects`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `projects` (
`id` INT NOT NULL,
`name` VARCHAR(100) NOT NULL,
`serverprojects_id` INT NOT NULL,
`users_id` INT NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_projects_serverprojects_idx` (`serverprojects_id` ASC),
INDEX `fk_projects_users1_idx` (`users_id` ASC),
CONSTRAINT `fk_projects_serverprojects`
FOREIGN KEY (`serverprojects_id`)
REFERENCES `serverprojects` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_projects_users1`
FOREIGN KEY (`users_id`)
REFERENCES `users` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB [50004-193] HY004/50004 (Help)

有人知道这是怎么回事吗?我认为问题出在 INDEX fk_projects_serverprojects_idx (serverprojects_id ASC) 的语法内部,但我无法让它工作

最佳答案

我刚刚发现问题是这样的:

INDEX `fk_projects_serverprojects_idx` (`serverprojects_id` ASC), 
INDEX `fk_projects_users1_idx` (`users_id` ASC),

与InnoDB结合。对于 InnoCb,您不允许这样做。

关于mysql - fk 引用上的未知数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43343906/

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