Innodb Error 150
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about mysql error 1005 can't create table hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask
Mysql Error 1005 Errno 121
Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join
Mysql Error 1005 Errno 150
them; it only takes a minute: Sign up MySQL InnoDB table adding foreign key errno:150 up vote 1 down vote favorite Well, i have two tables publica_evento_grupo Field | Type | Null | Key | Default | Extra id_evento_grupo
Mysql Error 1005 (hy000)
int(10) unsigned NO PRI auto_increment id_evento int(8) unsigned NO MUL id_grupo int(8) unsigned NO MUL identificacao varchar(55) NO publica_identificacao_publicacao Field | Type | Null | Key | Default | Extra id_evento int(8) unsigned NO PRI identificacao varchar(55) NO PRI publica_evento_grupo.id_evento in is a foreign key to a third table called publica_evento but is also a foreign key together with the column to the table publica_identificacao_publicacao.identificacao. The problem is, I got to create the foreign key that relates publica_evento_grupo error 1005 cloudflare to publica_identificacao_publicacao by the key id_evento, but when I try to create the another FK with the column identificacao, it gives the errno below [Err] 1005 - Can't create table '#sql-1049_1980992' (errno: 150). As you can see the table publica_identificacao_publicacao has two PK and that iss the reason that it has to be 2 FK to relate them, i didn't create the indexes yet, because as far as i know, i just have to create the indexes after adding the FK contraints, and I was able to create the FK contraint to the column id_evento between evento_grupo and identificacao_publicacao, i don't know why just the column identificacao is giving this error EDIT 1: @RolandBouman i don't have the permission to use that command SHOW ENGINE INNODB STATUS EDIT 2: @Geoff_Montee acctually the command you passed worked, to undestand why i use that structure take a look at this question MySQL UNIQUE Constraint multiple columns condition mysql sql entity-relationship foreign-key-relationship indexing share|improve this question edited Oct 29 '12 at 16:40 asked Oct 26 '12 at 20:09 Murilo 71111 Do a SHOW ENGINE INNODB STATUS right after you encounter this error, and look for the heading LAST FOREIGN KEy ERROR in the output. Probably this is just a datatype mismatch. –Roland Bouman Oct 26 '12 at 20:41 add a comment| 2 Answers 2 active oldest votes up vote 0 down vote accepted That er
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings error 1005 mysql and policies of this site About Us Learn more about Stack Overflow error no 150 in mysql the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags error 1005 hy000 can t create table errno 150 Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only http://stackoverflow.com/questions/13093732/mysql-innodb-table-adding-foreign-key-errno150 takes a minute: Sign up MySQL Foreign Key Error 1005 errno 150 up vote 31 down vote favorite 8 I'm doing a small DataBase with MySQL Workbench. I have a main table, called "Immobili", which has a Primary Key composed by four columns: (Comune, Via, Civico, Immobile). Now, I also have three other tables, wich have the same primary key http://stackoverflow.com/questions/4063141/mysql-foreign-key-error-1005-errno-150 (Comune, Via, Civico, Immobile), but these fields are also referenced to the table Immobili. First question: Can I make a Primary Key that is also a Foreign Key? Second Question: When I try to export the changes it says: Executing SQL script in server # ERROR: Error 1005: Can't create table 'dbimmobili.condoni' (errno: 150) CREATE TABLE IF NOT EXISTS `dbimmobili`.`Condoni` ( `ComuneImmobile` VARCHAR(50) NOT NULL , `ViaImmobile` VARCHAR(50) NOT NULL , `CivicoImmobile` VARCHAR(5) NOT NULL , `InternoImmobile` VARCHAR(3) NOT NULL , `ProtocolloNumero` VARCHAR(15) NULL , `DataRichiestaSanatoria` DATE NULL , `DataSanatoria` DATE NULL , `SullePartiEsclusive` TINYINT(1) NULL , `SullePartiComuni` TINYINT(1) NULL , `OblazioneInEuro` DOUBLE NULL , `TecnicoOblazione` VARCHAR(45) NULL , `TelefonoTecnico` VARCHAR(15) NULL , INDEX `ComuneImmobile` (`ComuneImmobile` ASC) , INDEX `ViaImmobile` (`ViaImmobile` ASC) , INDEX `CivicoImmobile` (`CivicoImmobile` ASC) , INDEX `InternoImmobile` (`InternoImmobile` ASC) , PRIMARY KEY (`ComuneImmobile`, `ViaImmobile`, `CivicoImmobile`, `InternoImmobile`) , CONSTRAINT `ComuneImmobile` FOREIGN KEY (`ComuneImmobile` ) REFERENCES `dbimmobili`.`Immobile` (`ComuneImmobile` ) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ViaImmobile` FOREIGN KEY (`ViaImmobile` ) REFERENCES `dbimmobili`.`Immobile` (`ViaImmobile` ) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `CivicoImmobile` FOREIGN KEY (`CivicoImmobile` ) REFERENCES `dbimmobili`.
log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of http://dba.stackexchange.com/questions/80435/mysql-create-table-shows-error-1005-errno-150 this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Database Administrators Questions Tags Users Badges Unanswered Ask Question _ Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a error 1005 minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Mysql Create table shows ERROR 1005 errno 150 up vote 0 down vote favorite I am trying to make a junction table, but I getting a ERROR 1005 errno 150 CREATE TABLE 61furiousFistPokemon( cardNumber int NOT NULL PRIMARY mysql error 1005 KEY, pokemonName VARCHAR(12), type VARCHAR(10), stage VARCHAR(10), evolvesFrom VARCHAR(12), HP INT, retreatCost INT, weakness VARCHAR(10), weaknessAmount VARCHAR(5), resistance VARCHAR(5), resistanceAmount VARCHAR(5) ); CREATE TABLE cardTags ( tagId int NOT NULL AUTO_INCREMENT PRIMARY KEY, tagName VARCHAR(60) NOT NULL ); CREATE TABLE 61furiousFistPokemonTags ( tagId int NOT NULL AUTO_INCREMENT PRIMARY KEY, pokemonCardNumber int, tagName VARCHAR(60), FOREIGN KEY (pokemonCardNumber) REFERENCES 61furiousFistPokemon(cardNumber), FOREIGN KEY (tagName) REFERENCES cardTags(tagName) ); Any help would be greatly appreciated. mysql innodb foreign-key table share|improve this question edited Oct 17 '14 at 15:23 RolandoMySQLDBA 108k15139274 asked Oct 17 '14 at 3:43 user50479 add a comment| 3 Answers 3 active oldest votes up vote 1 down vote tagName column in table cardTags is not defined as primary key and you are declaring foreign key FOREIGN KEY (tagName) REFERENCES cardTags(tagName). share|improve this answer answered Oct 17 '14 at 8:13 Nawaz Sohail 611314 Although you did not provide a solution, +1 for revealing root cause. –RolandoMySQLDBA Oct 17 '14 at 15:19 add a comment| up vote 0 down vote Very often it happens, when the foreign key and the reference key don't have same type or same length. Click here for more details.