Mysql Error Code 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 hiring developers or posting ads with error 121 in mysql us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow
Error 150 In Mysql Alter Table
Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up mysql error 150 foreign key MySql Error 150 - Foreign keys up vote 13 down vote favorite 2 When I execute the follow two queries (I have stripped them down to absolutely necessary): mysql> CREATE TABLE foo(id INT PRIMARY KEY); Query OK, 0 rows affected (0.01 sec)
Mysql Error 1005
mysql> CREATE TABLE bar ( id INT, ref INT, FOREIGN KEY (ref) REFERENCES foo(id)) ENGINE InnoDB; I get the following error: ERROR 1005 (HY000): Can't create table './test/bar.frm' (errno: 150) Where the **** is my error? I haven't found him while staring at this for half an hour. mysql mysql-error-1005 share|improve this question edited Apr 30 '11 at 17:18 OMG Ponies 199k37360417 asked May 5 '09 at 15:14 Martin Thurau 4,73842561 add a comment| 7 Answers 7 active oldest votes up vote 25 down mysql error 150 can't create table vote accepted From FOREIGN KEY Constraints If you re-create a table that was dropped, it must have a definition that conforms to the foreign key constraints referencing it. It must have the right column names and types, and it must have indexes on the referenced keys, as stated earlier. If these are not satisfied, MySQL returns error number 1005 and refers to error 150 in the error message. My suspicion is that it's because you didn't create foo as InnoDB, as everything else looks OK. Edit: from the same page - Both tables must be InnoDB tables and they must not be TEMPORARY tables. share|improve this answer answered May 5 '09 at 15:22 Greg 199k35307303 A bit of quick testing, creating a foo as above with MyISAM, and a bar with InnoDB, suggests that that's the case - try double-checking your table type for foo. –Rob May 5 '09 at 15:26 +1 for "Both tables must be InnoDB tables", thanks a lot! –sanbhat Mar 4 '13 at 11:00 1 Even when both tables were InnoDB, I still had the same problem. I fixed it by created the index on the referred table before creating the foreign key. –iroegbu Sep 4 '13 at 17:29 yes. it should be innoDB. Thanks a lot –MAA Feb 20 '14 at 7:01 It doesn't help that MySQL Workbench 6.3 seems to randomly change the engine type to MyISAM from InnoDB when I'm creating new tables. &n
here for a quick overview of the site Help
Error Code 1005
Center Detailed answers to any questions you might have
Error 150 Chrome
Meta Discuss the workings and policies of this site About Us Learn more about mysql error 1025 Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask http://stackoverflow.com/questions/825362/mysql-error-150-foreign-keys Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MySql Error: #105 (Code 150). When I create my database schema I receive an error http://stackoverflow.com/questions/14888593/mysql-error-105-code-150-when-i-create-my-database-schema-i-receive-an-erro code of 150. up vote 4 down vote favorite DROP SCHEMA IF EXISTS `YouthMinistry` ; CREATE SCHEMA IF NOT EXISTS `YouthMinistry` DEFAULT CHARACTER SET utf16 COLLATE utf16_general_ci ; USE `YouthMinistry` ; -- ----------------------------------------------------- -- Table `YouthMinistry`.`group` -- ----------------------------------------------------- DROP TABLE IF EXISTS `YouthMinistry`.`group` ; CREATE TABLE IF NOT EXISTS `YouthMinistry`.`group` ( `groupid` INT NOT NULL AUTO_INCREMENT , `group_name` VARCHAR(100) NOT NULL , `group_desc` VARCHAR(255) NULL , PRIMARY KEY (`groupid`) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `YouthMinistry`.`groupmembers` -- ----------------------------------------------------- DROP TABLE IF EXISTS `YouthMinistry`.`groupmembers` ; CREATE TABLE IF NOT EXISTS `YouthMinistry`.`groupmembers` ( `groupid` INT NOT NULL , `memberid` INT NOT NULL , PRIMARY KEY (`groupid`, `memberid`) , INDEX `groupid_idx` (`groupid` ASC) , CONSTRAINT `groupid` FOREIGN KEY (`groupid` ) REFERENCES `YouthMinistry`.`group` (`groupid` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `YouthMinis
Community Podcasts MySQL.com Downloads Documentation Section Menu: MySQL Forums :: InnoDB :: mysql error code:150 New Topic Advanced Search Re: mysql http://forums.mysql.com/read.php?22,187954,224345 error code:150 Posted by: Alex Zinc () Date: August 29, http://forums.mysql.com/read.php?71,576294,576318 2008 07:56AM I faced this problem as well and when i specified the option engine=myisam, everything went well, but the foreign keys didn't work at all as myisam doesn't support them. One of the advices I saw here was to check whether the mysql error tables connected with foreign keys were running on the same engine, but I created them, including the one with foreign keys, without specifying the ingine, so they all must run on innodb, but nevertheless the error occurs. Why? Edited 2 time(s). Last edit at 08/30/2008 05:16AM by Alex Zinc. Navigate:Previous Message•Next Message Options:Reply•Quote Subject mysql error 150 Views Written By Posted mysql error code:150 19825 Gavy Singh 12/13/2007 01:18AM Re: mysql error code:150 8925 Noah Goodrich 12/21/2007 11:34PM Re: mysql error code:150 5926 Yeiguer Contreras 05/15/2008 07:40AM Re: mysql error code:150 5903 Alex Zinc 08/29/2008 07:56AM Sorry, you can't reply to this topic. It has been closed. powered by phorum 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. Contact Sales USA: +1-866-221-0634 Canada: +1-866-221-0634 Germany: +49 89 143 01280 France: +33 1 57 60 83 57 Italy: +39 02 249 59 120 UK: +44 207 553 8447 Japan: 0120-065556 China: 10800-811-0823 India: 0008001005870 More Countries» Contact Us Online» Products MySQL Enterprise Edition MySQL Standard Edition MySQL Classic Edition MySQL Cluster CGE MySQL Embedded (OEM/ISV) Services Training Certification Consulting Support Downloads MySQL Community Server MySQL Cluster MySQL Fabric MySQL Utilities
Community Podcasts MySQL.com Downloads Documentation Section Menu: MySQL Forums :: Spanish :: ERROR 1005 (HY000): No puedo crear tabla ... (Error: 150) New Topic Advanced Search Re: ERROR 1005 (HY000): No puedo crear tabla ... (Error: 150) Posted by: Jesus Uzcanga () Date: December 19, 2012 10:43AM Hola Adán Es un claro ejemplo de problemas con claves foraneas. Algo que te pudo haber ayudando desde un principio es lo siguiente: Muchas veces Mysql arroja un código de error y no sabemos exactamente que significa. Pues al instalar Mysql-server en un sistema operativo, el mismo, habilita una aplicación que permite conocer estos códigos... Para ejecutarla solo debes abrir una cónsola y usar el comando "perror" sin comillas, seguido del código del error. En este caso sería perror 150 Y el sistema operativo respondería: MySQL error code 150: Foreign key constraint is incorrectly formed Y con esto ya tienes al menos una guía de por donde esta el problema. ___________________________________________________________________________ Adicionalmente existe una forma de poder insertar/eliminar/modificar datos de una tabla sin importar las claves foraneas que posea. Esto obviamente es muy delicado por lo que debes hacer respaldos previamente y trabajar con cuidado. Simplemente debes agregar la cláusula "SET FOREIGN_KEY_CHECKS=0;" sin comillas al principio del el script y listo!!! Esto apaga la integridad referencial (relaciones de claves foraneas) momentaneamente (durante la ejecución del script) y te permite mover la data a tu gusto. Espero que te sirva ___________________________ Ing. Jesús Alfredo Uzcanga Twitter: @JesusUzcanga www.waywork.com Aprendemos el 20% de lo que escuchamos, el 50% de lo que vemos, el 80% de lo que hacemos y el 95% de lo que ENSEÑAMOS. ______________________________________________________