150 Mysql Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings mysql error 1005 and policies of this site About Us Learn more about Stack Overflow mysql error 121 the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation
Mysql Foreign Key
Tags 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;
Mysql Errno 150
it only takes a minute: Sign up 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> CREATE TABLE bar ( id INT, ref INT, FOREIGN KEY mysql error 1025 (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 198k36356415 asked May 5 '09 at 15:14 Martin Thurau 4,69342561 add a comment| 7 Answers 7 active oldest votes up vote 24 down 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
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss
Mysql Error 150 Rename
the workings and policies of this site About Us Learn more about mysql error 1064 Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow mysql alter table Questions Jobs Documentation Tags 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 http://stackoverflow.com/questions/825362/mysql-error-150-foreign-keys other. Join them; it only takes a minute: Sign up Error No 150 mySQL up vote 3 down vote favorite This is making me sweat - I am getting error 150 when I try and create a table in mySQL. I've scoured the forums to no avail. The statement uses foreign key constraints - both tables are InnoDB, http://stackoverflow.com/questions/2967140/error-no-150-mysql all relevant columns have the same data type and both tables have the same charset and collation. Here's the CREATE TABLE and the original CREATE TABLE statement for the table that's being referenced. Any ideas? New table: CREATE TABLE `approval` ( `rev_id` int(10) UNSIGNED NOT NULL, `rev_page` int(10) UNSIGNED NOT NULL, `user_id` int(10) UNSIGNED NOT NULL, `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`rev_id`,`rev_page`,`user_id`), KEY `FK_approval_user` (`user_id`), CONSTRAINT `FK_approval_revision` FOREIGN KEY (`rev_id`, `rev_page`) REFERENCES `revision` (`rev_id`, `rev_page`), CONSTRAINT `FK_approval_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; Referenced table: CREATE TABLE `revision` ( `rev_id` int(10) unsigned NOT NULL auto_increment, `rev_page` int(10) unsigned NOT NULL, `rev_text_id` int(10) unsigned NOT NULL, `rev_comment` tinyblob NOT NULL, `rev_user` int(10) unsigned NOT NULL default '0', `rev_user_text` varbinary(255) NOT NULL default '', `rev_timestamp` binary(14) NOT NULL default '\0\0\0\0\0\0\0\0\0\0\0\0\0\0', `rev_minor_edit` tinyint(3) unsigned NOT NULL default '0', `rev_deleted` tinyint(3) unsigned NOT NULL default '0', `rev_len` int(10) unsigned default NULL, `rev_parent_id` int(10) unsigned default NULL, PRIMARY KEY (`rev_id`), UNIQUE KEY `rev_page_id` (`rev_page`,`rev_id`), KEY `rev_timestamp` (`rev_timestamp`), KEY `page_timestamp` (`rev_page`,`rev_timestamp`), K
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 this site About Us Learn more about Stack Overflow the company http://dba.stackexchange.com/questions/5437/mysql-foreign-key-cant-create-table-error-150 Business Learn more about hiring developers or posting ads with us Database Administrators Questions Tags http://forums.mysql.com/read.php?22,19755,19755 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 minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up mysql error and rise to the top MySQL, foreign key, can't create table error 150 up vote 5 down vote favorite 1 UPDATE: Sorry, it was because i forgot to add UNSIGNED attribute to the lang_id column. Original: I'm trying to create a table with foreign key in MySQL. I get this error: #1005 - Can't create table 'xy.trans' (errno: 150) Any ideas whats wrong with the following create statement? CREATE TABLE IF NOT EXISTS `lang` ( 150 mysql error `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `code` CHAR(2) NOT NULL, PRIMARY KEY (`id`) ) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `trans` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `something` TEXT NOT NULL, `lang_id` INT NULL, PRIMARY KEY (`id`), INDEX `index_trans_lang` (`lang_id` ASC), CONSTRAINT `fk_trans_lang` FOREIGN KEY (`lang_id` ) REFERENCES `lang` (`id` ) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE = InnoDB; mysql foreign-key share|improve this question edited Jan 14 '13 at 12:07 Akash 512318 asked Sep 6 '11 at 10:39 Ben 2613 Ah, +1 for solving your own problem !!! –RolandoMySQLDBA Sep 6 '11 at 15:00 3 @Ben, if you would be so kind as to post your answer as an answer proper, and mark it accepted, you'll get upvotes (higher rep) and it'll be more clear what transpired here. –jcolebrand♦ Sep 6 '11 at 18:08 add a comment| 2 Answers 2 active oldest votes up vote 1 down vote I've had a similar problem with this, and I finally resolved it by checking the field types of the two fields that were being referenced - they have to be exactly the same type - all the way down to the "Not NUll" and "Unsigned" settings... In your original post, the "lang" table has the "id" field defined as "INT UNSIGNED NOT NULL", whereas the
Community Podcasts MySQL.com Downloads Documentation Section Menu: MySQL Forums :: InnoDB :: ERROR 1005: Can't create table (errno: 150) New Topic Advanced Search ERROR 1005: Can't create table (errno: 150) Posted by: elmpie () Date: March 24, 2005 01:20PM I'm using the MySql version that comes with the Debian Sarge. (mysql Ver 12.22 Distrib 4.0.23, for pc-linux-gnu (i386)) I already have one database that has a few tables with foreign keys. I've created a anew database and it seems impossible to put new foreign keys on these tables? So I've tried the most basic thing ans its still not working. create table test1 (pk_alias int not null auto_increment, primary key (pk_alias)) type=innodb; create table test2 (pk_alias2 int unsigned not null auto_increment, fk_test1 int not null, primary key (pk_alias2), foreign key (fk_test1) references test1(pk_alias)) type=innodb; I don't really get it. What am I doing wrong?? Thanks! Navigate:Previous Message•Next Message Options:Reply•Quote Subject Views Written By Posted ERROR 1005: Can't create table (errno: 150) 640916 elmpie 03/24/2005 01:20PM Re: ERROR 1005: Can't create table (errno: 150) 304027 Martin Lukasiewycz 03/28/2005 02:15PM Re: ERROR 1005: Can't create table (errno: 150) 215386 KimSeong Loh 03/29/2005 08:42PM Re: ERROR 1005: Can't create table (errno: 150) 155591 Michael Buell 05/30/2005 10:29AM Re: ERROR 1005: Can't create table (errno: 150) 149708 Chris Yuan 10/27/2005 11:01PM Re: ERROR 1005: Can't create table (errno: 150) 92322 Deepak Kumar 03/14/2008 11:45PM ERROR 1005: Can't create table (errno: 150) 72362 Pradeep Max 07/07/2008 09:00AM Re: ERROR 1005: Can't create table (errno: 150) 49749 karthik sakthi 03/12/2009 07:38AM Re: ERROR 1005: Can't create table (errno: 150) Global solution 50888 Mayur P Vegad 06/23/2010 08:13AM Re: ERROR 1005: Can't create table (errno: 150) Global solution 20514 B S 08/13/2011 09:04PM unfortunately not 4816 Gavin Stokes 10/09/2012 09:48PM Re: ERROR 1005: Can't create table (errno: 150) 37416 Agyeya Gupta 04/26/2009 06:23AM Re: ERROR 1005: Can't create table (errno: 150) 25597 Chris Walker 06/28/2009 12:40PM Re: ERROR 1005: Can't create table (errno: 150) [SOLVED] 48468 Chris Walker 06/28/2009 12:41PM Re: ERROR 1005: Can't create table (errno: 150) [SOLVED] 29129 Jitendra Gupta 09/04/2009 02:30AM Re: ERROR 1005: Can't create table (errno: 150) [ANOTHER SOLUTION] 29764 Jim Smith 01/11/2010 10:23AM