错误:错误1005:无法创建表(errno:121)

我将forward engineering我的MySQL数据库插入WAMP服务器时遇到了麻烦。我打算发布模式的图像,但这是我不能的第一篇文章。


下面是执行的脚本。


use aquaticstar;


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='TRADITIONAL,ALLOW_INVALID_DATES';


-- -----------------------------------------------------

-- Table `Students`

-- -----------------------------------------------------

DROP TABLE IF EXISTS `Students` ;


CREATE  TABLE IF NOT EXISTS `Students` (

  `id` VARCHAR(10) NOT NULL ,

  `studentName` VARCHAR(45) NOT NULL ,

  `gender` CHAR NOT NULL ,

  `birthDate` DATETIME NOT NULL ,

  `mNo` VARCHAR(10) NOT NULL ,

  `contactName` VARCHAR(45) NOT NULL ,

  `contactEmail` VARCHAR(45) NOT NULL ,

  `contactPhone` INT(10) NOT NULL ,

  `startDate` DATETIME NOT NULL ,

  `remarks` VARCHAR(200) NULL ,

  PRIMARY KEY (`id`) )

ENGINE = InnoDB;


-- -----------------------------------------------------

-- Table `Waiting List`

-- -----------------------------------------------------

DROP TABLE IF EXISTS `Waiting List` ;


CREATE  TABLE IF NOT EXISTS `Waiting List` (

  `wait_id` VARCHAR(5) NOT NULL ,

  `name` VARCHAR(45) NULL ,

  `contactName` VARCHAR(45) NULL ,

  `contactPhone` INT(10) NULL ,

  `contactEmail` VARCHAR(45) NULL ,

  `status` CHAR NULL ,

  `remarks` VARCHAR(200) NULL ,

  PRIMARY KEY (`wait_id`) )

ENGINE = InnoDB;


-- -----------------------------------------------------

-- Table `Schedule`

-- -----------------------------------------------------

DROP TABLE IF EXISTS `Schedule` ;

COMMIT;


-- -----------------------------------------------------

-- Data for table `Attendance`

-- -----------------------------------------------------

START TRANSACTION;

INSERT INTO `Attendance` (`date`, `attendance`, `link_id`) VALUES ('26/9/2012', '1', NULL);


COMMIT;

但是然后我得到这个错误:


Executing SQL script in server

ERROR: Error 1005: Can't create table 'aquaticstar.link' (errno: 121)

我不知道为什么。谁能帮我?


SMILET
浏览 715回答 3
3回答

狐的传说

我迅速搜寻了你,它把我带到了这里。我引用:如果您尝试添加名称已经在其他地方使用的约束,则会收到此消息要检查约束,请使用以下SQL查询:SELECT    constraint_name,    table_nameFROM    information_schema.table_constraintsWHERE    constraint_type = 'FOREIGN KEY'AND table_schema = DATABASE()ORDER BY    constraint_name;在此处查找更多信息,或尝试查看错误发生的位置。看起来像是我的外键有问题。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

MySQL