MySQL Forums :: InnoDB :: #1005 - Can't create table (errno: 150)


Advanced Search

#1005 - Can't create table (errno: 150)
Posted by: Igor Werner ()
Date: May 26, 2013 03:22PM

Can you help me with this code? I don;t have any idea why it doesn't working, it's very important to me. please help

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';

CREATE SCHEMA IF NOT EXISTS `baza_Odzga` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `baza_Odzga` ;

-- -----------------------------------------------------
-- Table `baza_Odzga`.`Charakterystyki`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `baza_Odzga`.`Charakterystyki` (
`Char_id` INT(11) NOT NULL AUTO_INCREMENT ,
`Char_wzrost` TINYINT(3) UNSIGNED NULL DEFAULT 0 ,
`Char_kolor_oczu` VARCHAR(25) NULL ,
`Char_plec` ENUM('M', 'K', 'BD') NULL DEFAULT 'BD' ,
`Char_kolor_wlosow` VARCHAR(25) NULL ,
`Char_znaki_szczegolne` TEXT NULL ,
PRIMARY KEY (`Char_id`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_polish_ci;


-- -----------------------------------------------------
-- Table `baza_Odzga`.`Sady`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `baza_Odzga`.`Sady` (
`Sad_id` INT(11) NOT NULL AUTO_INCREMENT ,
`Sad_nazwa` VARCHAR(45) NULL ,
`Sad_miejscowosc` VARCHAR(45) NULL ,
`Sad_adres` MEDIUMTEXT NULL ,
`Sad_telefon` INT(9) NULL ,
PRIMARY KEY (`Sad_id`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_polish_ci;


-- -----------------------------------------------------
-- Table `baza_Odzga`.`Jednostki`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `baza_Odzga`.`Jednostki` (
`Jed_id` INT(11) NOT NULL AUTO_INCREMENT ,
`Jed_nazwa` VARCHAR(45) NULL ,
`Jed_adres` VARCHAR(45) NULL ,
`Jed_dowodca` VARCHAR(45) NOT NULL ,
`Jed_jednostka_nadrzedna` VARCHAR(45) NULL ,
`Jed_komisariat` VARCHAR(45) NULL ,
PRIMARY KEY (`Jed_id`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_polish_ci;



-- -----------------------------------------------------
-- Table `baza_Odzga`.`Nakazy`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `baza_Odzga`.`Nakazy` (
`Nak_id` INT(11) NOT NULL AUTO_INCREMENT ,
`Sad_id` INT(11) NOT NULL COMMENT 'Id sądu wystawiającego' ,
`Fun_id` INT(11) NOT NULL COMMENT 'Id funkcjonariusza odpowiedzialnego za wykonanie' ,
`Nak_artykul` VARCHAR(45) NULL ,
`Nak_opis` TEXT NULL ,
`Nak_data_wystawienia` DATE NULL ,
`Nak_data_aktualizacji` TIMESTAMP NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY (`Nak_id`) ,
INDEX `FK_Sad_Nak_id_idx` (`Sad_id` ASC) ,
INDEX `FK_Fun_Nak_id_idx` (`Fun_id` ASC) ,
CONSTRAINT `FK_Sad_Nak_id`
FOREIGN KEY (`Sad_id` )
REFERENCES `baza_Odzga`.`Sady` (`Sad_id` )
ON DELETE NO ACTION
ON UPDATE CASCADE,
CONSTRAINT `FK_Fun_Nak_id`
FOREIGN KEY (`Fun_id` )
REFERENCES `baza_Odzga`.`Funkcjonariusze` (`Fun_id` )
ON DELETE SET NULL
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_polish_ci;


-- -----------------------------------------------------
-- Table `baza_Odzga`.`Rejestr_Przestepstw`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `baza_Odzga`.`Rejestr_Przestepstw` (
`Rej_id` INT(11) NOT NULL AUTO_INCREMENT ,
`Rej_skazani_pesele` VARCHAR(255) NOT NULL COMMENT 'Pesel osób skazanych ' ,
`Rej_artykul` VARCHAR(45) NOT NULL ,
`Rej_data_wyroku` DATE NOT NULL ,
`Sad_id` INT(11) NOT NULL COMMENT 'Id sądu skazującego' ,
`Rej_opis` TEXT NULL ,
PRIMARY KEY (`Rej_id`) ,
INDEX `FK_Sad_Rej_id_idx` (`Sad_id` ASC) ,
CONSTRAINT `FK_Sad_Rej_id`
FOREIGN KEY (`Sad_id` )
REFERENCES `baza_Odzga`.`Sady` (`Sad_id` )
ON DELETE NO ACTION
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_polish_ci;


-- -----------------------------------------------------
-- Table `baza_Odzga`.`Poszukiwani`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `baza_Odzga`.`Poszukiwani` (
`Posz_id` INT(11) NOT NULL AUTO_INCREMENT ,
`Char_id` INT(11) NOT NULL ,
`Pesel` BIGINT(11) UNSIGNED NULL ,
`Posz_imie` VARCHAR(45) NULL ,
`Posz_nazwisko` VARCHAR(45) NULL ,
`Nak_id` INT(11) NULL ,
`Posz_Karany` ENUM('T', 'N', 'BD') NULL DEFAULT 'BD' ,
`Rej_id` INT(11) NULL DEFAULT 0 ,
`Posz_ostatnio_widziany` TEXT NULL ,
`Posz_drugie_imie` VARCHAR(25) NULL ,
`Posz_imie_ojca` VARCHAR(25) NULL ,
`Posz_nazwisko_panienskie` VARCHAR(45) NULL ,
`Posz_miejsce_urodzenia` VARCHAR(45) NULL ,
`Posz_data_urodzenia` DATE NULL ,
PRIMARY KEY (`Posz_id`) ,
UNIQUE INDEX `Pesel_UNIQUE` (`Pesel` ASC) ,
UNIQUE INDEX `Char_id_UNIQUE` (`Char_id` ASC) ,
UNIQUE INDEX `Nak_id_UNIQUE` (`Nak_id` ASC) ,
INDEX `FK_Rej_Posz_id_idx` (`Rej_id` ASC) ,
INDEX `FK_Nak_Posz_id_idx` (`Nak_id` ASC, `Posz_id` ASC) ,
CONSTRAINT `FK_Nak_Posz_id`
FOREIGN KEY (`Nak_id` , `Posz_id` )
REFERENCES `baza_Odzga`.`Nakazy` (`Nak_id` , `Nak_id` )
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `FK_Char_Posz_id`
FOREIGN KEY (`Char_id` )
REFERENCES `baza_Odzga`.`Charakterystyki` (`Char_id` )
ON DELETE RESTRICT
ON UPDATE RESTRICT,
CONSTRAINT `FK_Rej_Posz_id`
FOREIGN KEY (`Rej_id` )
REFERENCES `baza_Odzga`.`Rejestr_Przestepstw` (`Rej_id` )
ON DELETE NO ACTION
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_polish_ci;


-- -----------------------------------------------------
-- Table `baza_Odzga`.`Nagrody`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `baza_Odzga`.`Nagrody` (
`Nag_id` INT(11) NOT NULL AUTO_INCREMENT ,
`Jed_id` INT(11) NOT NULL COMMENT 'Id jednostki wystawiającej' ,
`Nag_nazwa` VARCHAR(25) NOT NULL ,
`Nag_rodzaj` VARCHAR(25) NOT NULL ,
`Nag_opis` TEXT NULL ,
`Nag_data_wystawienia` DATE NOT NULL ,
`Nag_zakonczona` ENUM('T', 'N') NULL DEFAULT 'N' ,
`Fun_id` INT(11) NULL DEFAULT 0 COMMENT 'Id funkcjonariusza który otrzymał nagrodę' ,
`Nag_data_zakonczenia` TIMESTAMP NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY (`Nag_id`) ,
INDEX `FK_Jed_Nag_id_idx` (`Jed_id` ASC) ,
INDEX `FK_Fun_Nag_id_idx` (`Fun_id` ASC) ,
CONSTRAINT `FK_Jed_Nag_id`
FOREIGN KEY (`Jed_id` )
REFERENCES `baza_Odzga`.`Jednostki` (`Jed_id` )
ON DELETE NO ACTION
ON UPDATE CASCADE,
CONSTRAINT `FK_Fun_Nag_id`
FOREIGN KEY (`Fun_id` )
REFERENCES `baza_Odzga`.`Funkcjonariusze` (`Fun_id` )
ON DELETE SET NULL
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_polish_ci;


-- -----------------------------------------------------
-- Table `baza_Odzga`.`adm_uzytkownicy`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `baza_Odzga`.`adm_uzytkownicy` (
`Uzy_id` INT(11) NOT NULL AUTO_INCREMENT ,
`Fun_id` INT(11) NOT NULL ,
`Uzy_login` VARCHAR(45) NOT NULL ,
`Uzy_passwd` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`Uzy_id`) ,
UNIQUE INDEX `Fun_id_UNIQUE` (`Fun_id` ASC) ,
UNIQUE INDEX `Uzy_login_UNIQUE` (`Uzy_login` ASC) ,
CONSTRAINT `FK_Fun_Uzy`
FOREIGN KEY (`Fun_id` )
REFERENCES `baza_Odzga`.`Funkcjonariusze` (`Fun_id` )
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_polish_ci;


-- -----------------------------------------------------
-- Table `baza_Odzga`.`adm_moduly`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `baza_Odzga`.`adm_moduly` (
`Mod_id` INT NOT NULL AUTO_INCREMENT ,
`Mod_nazwa` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`Mod_id`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_polish_ci;


-- -----------------------------------------------------
-- Table `baza_Odzga`.`adm_role`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `baza_Odzga`.`adm_role` (
`Uzy_id` INT(11) NOT NULL ,
`Mod_id` INT(11) NOT NULL ,
`Rol_read` TINYINT(1) NOT NULL DEFAULT 0 ,
`Rol_write` TINYINT(1) NOT NULL DEFAULT 0 ,
`Rol_delete` TINYINT(1) NOT NULL DEFAULT 0 ,
INDEX `FK_Uzy_Rol_id_idx` (`Uzy_id` ASC) ,
INDEX `FK_Mod_Rol_id_idx` (`Mod_id` ASC) ,
CONSTRAINT `FK_Uzy_Rol_id`
FOREIGN KEY (`Uzy_id` )
REFERENCES `baza_Odzga`.`adm_uzytkownicy` (`Uzy_id` )
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `FK_Mod_Rol_id`
FOREIGN KEY (`Mod_id` )
REFERENCES `baza_Odzga`.`adm_moduly` (`Mod_id` )
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_polish_ci;

USE `baza_Odzga` ;


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

Options: ReplyQuote


Subject Views Written By Posted
#1005 - Can't create table (errno: 150) 3328 Igor Werner 05/26/2013 03:22PM
Re: #1005 - Can't create table (errno: 150) 1902 Peter Brawley 05/26/2013 10:00PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.