Pesquisar na Comunidade
Mostrando resultados para as tags ''innodb''.
Encontrado 1 registro
-
Boa noite. Realizei uma engenharia avante no mysql workbench de um DER e tentei executar o código resultante contudo obtive o erro mencionado no título. Por este motivo, executei show engine innodb status e na seção latest foreign key error, estava escrito: LATEST FOREIGN KEY ERROR ------------------------ 2014-11-10 18:56:51 ad4 Error in foreign key constraint of table basebd/base_has_pesquisador: FOREIGN KEY (`PESQUISADOR_IDPESQUISADOR`) REFERENCES `BASEBD`.`PESQUISADOR` (`IDPESQUISADOR`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB: Cannot find an index in the referenced table where the referenced columns appear as the first columns, or column types in the table and the referenced table do not match for constraint. Note that the internal storage type of ENUM and SET changed in tables created with >= InnoDB-4.1.12, and such columns in old tables cannot be referenced by such columns in new tables. See http://dev.mysql.com/doc/refman/5.6/en/innodb-foreign-key-constraints.html for correct foreign key definition. porém, eu não entendi o que aconteceu. Por favor, o sql gerado se encontra abaixo e o problema ocorre numa tabela chamada Base_has_pesquisador que é uma tabela resultante de um relacionamento muitos para muitos entre a tabela base e a tabela pesquisador, ou seja, contém duas chaves primárias que são também chaves estrangeiras para as tabelas supracitadas. 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 BASEBD -- ----------------------------------------------------- CREATE SCHEMA IF NOT EXISTS `BASEBD` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ; USE `BASEBD` ; -- ----------------------------------------------------- -- Table `BASEBD`.`PESQUISADOR` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `BASEBD`.`PESQUISADOR` ( `IDPESQUISADOR` INT UNSIGNED NOT NULL AUTO_INCREMENT, `NOME` VARCHAR(45) NOT NULL, `IDADE` INT UNSIGNED NOT NULL, `SEXO` CHAR NOT NULL, `ISATIVO` CHAR NOT NULL, `INSTITUICAO` VARCHAR(45) NOT NULL, `EMAIL` VARCHAR(45) NOT NULL, `TELEFONE` VARCHAR(13) NOT NULL, `CEP` VARCHAR(9) NOT NULL, PRIMARY KEY (`IDPESQUISADOR`), UNIQUE INDEX `TELEFONE_UNIQUE` (`TELEFONE` ASC), UNIQUE INDEX `EMAIL_UNIQUE` (`EMAIL` ASC), UNIQUE INDEX `NOME_UNIQUE` (`NOME` ASC)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `BASEBD`.`BASE` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `BASEBD`.`BASE` ( `IDBASE` INT NOT NULL AUTO_INCREMENT, `NOME` VARCHAR(45) NOT NULL, PRIMARY KEY (`IDBASE`), UNIQUE INDEX `NOME_UNIQUE` (`NOME` ASC)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `BASEBD`.`CARACTERISTICA` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `BASEBD`.`CARACTERISTICA` ( `IDCARACTERISTICA` INT NOT NULL AUTO_INCREMENT, `NOME` VARCHAR(45) NOT NULL, `DESCRICAO` BLOB NULL, `BASE_IDBASE` INT NOT NULL, PRIMARY KEY (`IDCARACTERISTICA`), INDEX `fk_CARACTERISTICA_BASE1_idx` (`BASE_IDBASE` ASC), UNIQUE INDEX `NOME_UNIQUE` (`NOME` ASC), CONSTRAINT `fk_CARACTERISTICA_BASE1` FOREIGN KEY (`BASE_IDBASE`) REFERENCES `BASEBD`.`BASE` (`IDBASE`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `BASEBD`.`CLASSE` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `BASEBD`.`CLASSE` ( `IDCLASSE` INT NOT NULL AUTO_INCREMENT, `NOME` VARCHAR(45) NOT NULL, `BASE_IDBASE` INT NOT NULL, PRIMARY KEY (`IDCLASSE`), INDEX `fk_CLASSE_BASE1_idx` (`BASE_IDBASE` ASC), UNIQUE INDEX `NOME_UNIQUE` (`NOME` ASC), CONSTRAINT `fk_CLASSE_BASE1` FOREIGN KEY (`BASE_IDBASE`) REFERENCES `BASEBD`.`BASE` (`IDBASE`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `BASEBD`.`LINHA` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `BASEBD`.`LINHA` ( `IDLINHA` INT NOT NULL AUTO_INCREMENT, `NUM` INT NOT NULL, `BASE_IDBASE` INT NOT NULL, `CLASSE_IDCLASSE` INT NOT NULL, PRIMARY KEY (`IDLINHA`), INDEX `fk_LINHA_BASE1_idx` (`BASE_IDBASE` ASC), INDEX `fk_LINHA_CLASSE1_idx` (`CLASSE_IDCLASSE` ASC), UNIQUE INDEX `NUM_UNIQUE` (`NUM` ASC), CONSTRAINT `fk_LINHA_BASE1` FOREIGN KEY (`BASE_IDBASE`) REFERENCES `BASEBD`.`BASE` (`IDBASE`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_LINHA_CLASSE1` FOREIGN KEY (`CLASSE_IDCLASSE`) REFERENCES `BASEBD`.`CLASSE` (`IDCLASSE`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `BASEBD`.`DADO` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `BASEBD`.`DADO` ( `IDDADO` INT NOT NULL AUTO_INCREMENT, `VALOR` DECIMAL(4,2) NOT NULL, `COLUNA` INT NOT NULL, `FK_IDBASE` INT NOT NULL, `FK_IDCARACTERISTICA` INT NOT NULL, `LINHA_IDLINHA` INT NOT NULL, PRIMARY KEY (`IDDADO`), INDEX `IDBASE_idx` (`FK_IDBASE` ASC), INDEX `FK_IDCARACTERISTICA_idx` (`FK_IDCARACTERISTICA` ASC), INDEX `fk_DADO_LINHA1_idx` (`LINHA_IDLINHA` ASC), CONSTRAINT `FK_IDBASE` FOREIGN KEY (`FK_IDBASE`) REFERENCES `BASEBD`.`BASE` (`IDBASE`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `FK_IDCARACTERISTICA` FOREIGN KEY (`FK_IDCARACTERISTICA`) REFERENCES `BASEBD`.`CARACTERISTICA` (`IDCARACTERISTICA`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_DADO_LINHA1` FOREIGN KEY (`LINHA_IDLINHA`) REFERENCES `BASEBD`.`LINHA` (`IDLINHA`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `BASEBD`.`BASE_has_PESQUISADOR` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `BASEBD`.`BASE_has_PESQUISADOR` ( `BASE_IDBASE` INT NOT NULL, `PESQUISADOR_IDPESQUISADOR` INT NOT NULL, PRIMARY KEY (`BASE_IDBASE`, `PESQUISADOR_IDPESQUISADOR`), INDEX `fk_BASE_has_PESQUISADOR_PESQUISADOR1_idx` (`PESQUISADOR_IDPESQUISADOR` ASC), INDEX `fk_BASE_has_PESQUISADOR_BASE1_idx` (`BASE_IDBASE` ASC), UNIQUE INDEX `BASE_IDBASE_UNIQUE` USING BTREE (`BASE_IDBASE` ASC, `PESQUISADOR_IDPESQUISADOR` ASC), UNIQUE INDEX `PESQUISADOR_IDPESQUISADOR_UNIQUE` (`PESQUISADOR_IDPESQUISADOR` ASC, `BASE_IDBASE` ASC), CONSTRAINT `fk_BASE_has_PESQUISADOR_BASE1` FOREIGN KEY (`BASE_IDBASE`) REFERENCES `BASEBD`.`BASE` (`IDBASE`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_BASE_has_PESQUISADOR_PESQUISADOR1` FOREIGN KEY (`PESQUISADOR_IDPESQUISADOR`) REFERENCES `BASEBD`.`PESQUISADOR` (`IDPESQUISADOR`) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
- 2 respostas
-
- mysql
- engenharia
- (e %d mais)