phpMyAdmin无法创建表

时间:2015-03-31 14:02:22

标签: mysql workbench

我需要为学校项目创建一个数据库,但它无法正常工作。每次我将以下内容导入数据库时​​,我都无法在group_rights创建表错误。我尝试过各种各样的事情。我试图一次运行sql one命令,但随后它崩溃了更多的表。

我做错了什么?

    -- MySQL Script generated by MySQL Workbench
-- 03/31/15 15:50:41
-- 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='TRADITIONAL,ALLOW_INVALID_DATES';

-- -----------------------------------------------------
-- Schema kevineb144_yii1
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema kevineb144_yii1
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `kevineb144_yii1` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `kevineb144_yii1` ;

-- -----------------------------------------------------
-- Table `kevineb144_yii1`.`user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `kevineb144_yii1`.`user` (
  `User_id` INT NOT NULL AUTO_INCREMENT,
  `Username` VARCHAR(45) NULL,
  `Password` VARCHAR(45) NULL,
  `First_name` VARCHAR(45) NULL,
  `Last_name` VARCHAR(45) NULL,
  `Day_Of_Birth` DATE NULL,
  `Address` VARCHAR(45) NULL,
  `Email_address` VARCHAR(45) NULL,
  `Phone_number` VARCHAR(45) NULL,
  PRIMARY KEY (`User_id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `kevineb144_yii1`.`group`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `kevineb144_yii1`.`group` (
  `Group_Id` INT NOT NULL,
  `Name` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`Group_Id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `kevineb144_yii1`.`user_group`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `kevineb144_yii1`.`user_group` (
  `User_Id` INT NOT NULL,
  `Group_Id` INT NOT NULL,
  INDEX `User_Id_idx` (`User_Id` ASC),
  INDEX `Group_Id_idx` (`Group_Id` ASC))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `kevineb144_yii1`.`rights`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `kevineb144_yii1`.`rights` (
  `Rights_Id` INT NOT NULL,
  `Name` VARCHAR(45) NOT NULL,
  `Description` VARCHAR(45) NOT NULL,
  `Default_Value` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`Rights_Id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `kevineb144_yii1`.`group_rights`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `kevineb144_yii1`.`group_rights` (
  `Group_Id` INT NOT NULL,
  `Rights_Id` INT NOT NULL,
  INDEX `Rights_Id_idx` (`Rights_Id` ASC))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `kevineb144_yii1`.`category`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `kevineb144_yii1`.`category` (
  `Category_id` INT NOT NULL AUTO_INCREMENT,
  `Name` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`Category_id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `kevineb144_yii1`.`factory`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `kevineb144_yii1`.`factory` (
  `Factory_id` INT NOT NULL AUTO_INCREMENT,
  `Name` VARCHAR(45) NOT NULL,
  `Address` VARCHAR(45) NOT NULL,
  `Email` VARCHAR(45) NULL,
  `Phone_Number` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`Factory_id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `kevineb144_yii1`.`subcategory`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `kevineb144_yii1`.`subcategory` (
  `Subcategory_id` INT NOT NULL AUTO_INCREMENT,
  `Category_id` INT NOT NULL,
  `Name` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`Subcategory_id`),
  INDEX `Category_idx` (`Category_id` ASC))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `kevineb144_yii1`.`product`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `kevineb144_yii1`.`product` (
  `Product_id` INT NOT NULL AUTO_INCREMENT,
  `Category_id` INT NOT NULL,
  `Subcategory_id` INT NOT NULL,
  `Name` VARCHAR(45) NOT NULL,
  `Type` VARCHAR(45) NOT NULL,
  `Cost_Price` FLOAT NOT NULL,
  `Retail_price` FLOAT NOT NULL,
  `Factory_id` INT NOT NULL,
  PRIMARY KEY (`Product_id`),
  INDEX `Category_idx` (`Category_id` ASC, `Subcategory_id` ASC),
  INDEX `Factory_idx` (`Factory_id` ASC),
  INDEX `Subcategory_idx` (`Subcategory_id` ASC))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `kevineb144_yii1`.`location`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `kevineb144_yii1`.`location` (
  `Location_Id` INT NOT NULL AUTO_INCREMENT,
  `Name` VARCHAR(45) NOT NULL,
  `Address` VARCHAR(45) NOT NULL,
  `Phone_Number` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`Location_Id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `kevineb144_yii1`.`inventory`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `kevineb144_yii1`.`inventory` (
  `Product_Id` INT NOT NULL,
  `Location_Id` INT NOT NULL,
  `Amount` INT NOT NULL,
  `Mutation` DATETIME NOT NULL,
  INDEX `Product_idx` (`Product_Id` ASC),
  INDEX `Location_idx` (`Location_Id` ASC))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `kevineb144_yii1`.`order`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `kevineb144_yii1`.`order` (
  `Order_Id` INT NOT NULL,
  `Order_date` DATETIME NOT NULL,
  `User_Id` INT NOT NULL,
  PRIMARY KEY (`Order_Id`),
  INDEX `User_Id_idx` (`User_Id` ASC))
ENGINE = InnoDB;


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

抱歉,我忘了在这里发布错误:

-- -----------------------------------------------------
-- Table `kevineb144_yii1`.`group_rights`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `kevineb144_yii1`.`group_rights` (
  `Group_Id` INT NOT NULL,
  `Rights_Id` INT NOT NULL,
  INDEX `Rights_Id_idx` (`Rights_Id` ASC),
  CONSTRAINT `Group_Id`
    FOREIGN KEY (`Group_Id`)
    REFERENCES `kevineb144_yii1`.`group` (`Group_Id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `Rights_Id`
    FOREIGN KEY (`Rights_Id`)
    REFERENCES `kevineb144_yii1`.`rights` (`Rights_Id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;
MySQL meldt: Documentatie

#1005 - Can't create table 'kevineb144_yii1.group_rights' (errno: 121) (Details…) 

0 个答案:

没有答案