0
我試圖導入MySQL工作臺創建成phpMyAdmin的(WAMP服務器),當我嘗試導入它,我得到一個數據庫錯誤:錯誤121不能創建表
MySQL said: Documentation
#1005 - Can't create table '.\mydb\team.frm' (errno: 121)
下面是執行SQL腳本
-- MySQL Script generated by MySQL Workbench
-- 03/03/15 13:06:58
-- Model: New Model Version: 1.0
SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @[email protected]@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;
USE `mydb` ;
-- -----------------------------------------------------
-- Table `mydb`.`Team`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Team` (
`id` INT NOT NULL AUTO_INCREMENT,
`referred_as` VARCHAR(45) NULL,
`TeamName` VARCHAR(45) NOT NULL,
`GoverningBody` VARCHAR(45) NOT NULL,
`Country` VARCHAR(45) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Competitor`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Competitor` (
`id` INT NOT NULL AUTO_INCREMENT,
`referred_as` VARCHAR(45) NULL,
`FirstName` VARCHAR(45) NOT NULL,
`Surname` VARCHAR(45) NOT NULL,
`Age` INT NOT NULL,
`Nationality` VARCHAR(45) NOT NULL,
`Title` VARCHAR(45) NOT NULL,
`ContactNumber` INT NOT NULL,
`team_id` DATETIME NOT NULL,
PRIMARY KEY (`id`),
INDEX `TeamID_idx` (`team_id` ASC),
CONSTRAINT `TeamID`
FOREIGN KEY (`team_id`)
REFERENCES `mydb`.`Team` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Card`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Card` (
`id` INT NOT NULL,
`referred_as` VARCHAR(45) NULL,
`IssueDate` DATE NOT NULL,
`ExpiryDate` DATE NOT NULL,
`Status` ENUM('Active','Expired','Lost') NOT NULL,
`competitor_id` INT NOT NULL,
PRIMARY KEY (`id`),
INDEX `CompetitorID_idx` (`competitor_id` ASC),
CONSTRAINT `CompetitorID`
FOREIGN KEY (`competitor_id`)
REFERENCES `mydb`.`Competitor` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Venue`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Venue` (
`id` INT NOT NULL,
`referred_as` VARCHAR(45) NULL,
`Stadium` VARCHAR(45) NOT NULL,
`Location` VARCHAR(45) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Fixture`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Fixture` (
`id` INT NOT NULL AUTO_INCREMENT,
`referred_as` VARCHAR(45) NULL,
`Time` TIME NOT NULL,
`Date` DATE NOT NULL,
`Type` VARCHAR(45) NOT NULL,
`venue_id` INT NOT NULL,
PRIMARY KEY (`id`),
INDEX `VenueID_idx` (`venue_id` ASC),
CONSTRAINT `VenueID`
FOREIGN KEY (`venue_id`)
REFERENCES `mydb`.`Venue` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Authorisation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Authorisation` (
`id` INT NOT NULL AUTO_INCREMENT,
`referred_as` VARCHAR(45) NULL,
`fixture_id` INT NOT NULL,
`card_id` INT NOT NULL,
PRIMARY KEY (`id`),
INDEX `FixtureID_idx` (`fixture_id` ASC),
INDEX `CardID_idx` (`card_id` ASC),
CONSTRAINT `FixtureID`
FOREIGN KEY (`fixture_id`)
REFERENCES `mydb`.`Fixture` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `CardID`
FOREIGN KEY (`card_id`)
REFERENCES `mydb`.`Card` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Log`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Log` (
`id` INT NOT NULL AUTO_INCREMENT,
`referred_as` VARCHAR(45) NULL,
`card_id` INT NOT NULL,
`venue_id` INT NOT NULL,
`LogTime` TIME NOT NULL,
`LogDate` DATE NOT NULL,
PRIMARY KEY (`id`),
INDEX `CardID_idx` (`card_id` ASC),
INDEX `VenueID_idx` (`venue_id` ASC),
CONSTRAINT `CardID`
FOREIGN KEY (`card_id`)
REFERENCES `mydb`.`Card` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `VenueID`
FOREIGN KEY (`venue_id`)
REFERENCES `mydb`.`Venue` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET [email protected]_SQL_MODE;
SET [email protected]_FOREIGN_KEY_CHECKS;
SET [email protected]_UNIQUE_CHECKS;
變化'TEAM_ID DATETIME NOT NULL,'來'TEAM_ID INT NOT NULL,' – 2015-03-03 13:32:27
做到了,不幸的是我仍然得到同樣的錯誤 – MikeyD 2015-03-03 13:41:48
還有像其他使用相同的索引名稱或約束名其他幾個錯誤已在前表中定義的表。 **例子**'Authorisation'和'Log'表中的'CardID_idx'。檢查其他人。 – 2015-03-03 13:45:01