Здравствуйте!
У меня уже слов литературных нет по поводу работы mySql Workbench. Я что не проектирую - не могу перенести потом phpMyAdmin. Почему все так через Жопэ??
Вот код, который любезно предоставил workBench:
-- MySQL Script generated by MySQL Workbench
-- Tue Mar 13 22:42:09 2018
-- 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 123
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema 123
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `123` DEFAULT CHARACTER SET utf8 ;
USE `123` ;
-- -----------------------------------------------------
-- Table `123`.`user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `123`.`user` (
`id` INT(11) NULL,
`username` VARCHAR(16) NOT NULL,
`email` VARCHAR(255) NOT NULL,
`password` VARCHAR(32) NOT NULL,
`create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`));
-- -----------------------------------------------------
-- Table `123`.`sub_category3`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `123`.`sub_category3` (
`id` INT(11) NOT NULL,
`name` VARCHAR(100) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `123`.`sub_category2`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `123`.`sub_category2` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(100) CHARACTER SET 'ucs2' NOT NULL,
`id_category` INT(11) NOT NULL,
PRIMARY KEY (`id`),
INDEX `sub_categoryes3_idx` (`id` ASC, `id_category` ASC),
CONSTRAINT `sub_categoryes3`
FOREIGN KEY (`id` , `id_category`)
REFERENCES `123`.`sub_category3` (`id` , `id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `123`.`category`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `123`.`category` (
`category_id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`sub_category2` INT(11) NOT NULL,
PRIMARY KEY (`category_id`),
INDEX `subcategoryes2_idx` (`sub_category2` ASC),
CONSTRAINT `subcategoryes2`
FOREIGN KEY (`sub_category2`)
REFERENCES `123`.`sub_category2` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
-- -----------------------------------------------------
-- Table `123`.`advert`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `123`.`advert` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`create_at` TIMESTAMP NULL,
`update_at` TIMESTAMP NULL,
`id_category` INT(11) NULL,
`levelCategory` TINYINT(2) NOT NULL,
`type` TINYINT(3) UNSIGNED NULL DEFAULT NULL COMMENT 'NULL-услуги, 1 - продам, 2-куплю, 3-меняю, 4-сниму, 5-сдам',
`email` VARCHAR(100) NOT NULL,
`phone` VARCHAR(90) NOT NULL,
`extra` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '0-нет, 1-обычная рамка, 2-жирная рамка',
`bold` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'false-без выделения жирным, true - выделить жирным',
`output_numbers` TINYINT(3) UNSIGNED NOT NULL COMMENT 'выход номеров',
`id_users` INT(11) NULL,
PRIMARY KEY (`id`),
INDEX `test_idx` (`id_users` ASC),
CONSTRAINT `user_id`
FOREIGN KEY (`id_users`)
REFERENCES `123`.`user` (`id`)
ON DELETE NO ACTION
ON UPDATE CASCADE)
ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARACTER SET = utf8;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
На это добро phpMyAdmin ругается
#1005 - Can't create table '123.sub_category2' (errno: 150)Подскажите пожалуйста, что где исправить нужно?