Executing Sql Script In Server Error Error 1005 Errno 121
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 mysql error code 1005. can't create table (errno 150) Overflow the company Business Learn more about hiring developers or posting ads with us
Sql Server Error 121
Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community mysql error no 150 of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Executing SQL script in server ERROR: Error 1005: Can't create table (errno: 150) up vote 0 errno 121 linux down vote favorite What could be the reason for this error? CREATE TABLE IF NOT EXISTS `myhotel`.`roomer` ( `id` INT NOT NULL , `name` VARCHAR(45) NOT NULL , `start` DATE NOT NULL , `finish` DATE NOT NULL , `day` INT NOT NULL , PRIMARY KEY (`id`) , INDEX `fk_id` (`id` ASC) , CONSTRAINT `fk_id` FOREIGN KEY (`id` ) REFERENCES `myhotel`.`all_roomers` (`id_roomer` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE
Mysql Error Code 121 Duplicate Key On Write Or Update
= InnoDB; CREATE TABLE IF NOT EXISTS `myhotel`.`all_roomers` ( `id_roomer` INT NOT NULL , `id_room` INT NOT NULL , `status` TINYINT(1) NOT NULL , INDEX `fk_id_room` (`id_room` ASC) , PRIMARY KEY (`id_roomer`, `id_room`) , CONSTRAINT `fk_id_room` FOREIGN KEY (`id_room` ) REFERENCES `myhotel`.`room` (`id` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `myhotel`.`room` ( `id` INT NOT NULL AUTO_INCREMENT , `number` INT NOT NULL , `price` INT NOT NULL , `capacity` INT NOT NULL , `stars` INT NOT NULL , `status` TINYINT(1) NOT NULL , PRIMARY KEY (`id`) ) ENGINE = InnoDB; The Error I get is : Executing SQL script in server ERROR: Error 1005: Can't create table 'myhotel.roomer' (errno: 150) mysql-error-1005 share|improve this question edited Jun 25 '12 at 16:54 asked Jun 25 '12 at 16:43 user1480528 1716 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote accepted According to the MySQL Docs (see here): If MySQL reports an error number 1005 from a CREATE TABLE statement, and the error message refers to error 150, table creation failed because a foreign key constraint was not correctly formed. I'd say from the looks of your script that it may be because the CREATE TABLE statement you're using
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 Business Learn mysql rename constraint more about hiring developers or posting ads with us Database Administrators Questions Tags Users Badges mysql error 1005 Unanswered Ask Question _ Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database
Error 1005 Can T Create Table
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 and rise to http://stackoverflow.com/questions/11193546/executing-sql-script-in-server-error-error-1005-cant-create-table-errno-150 the top Error creating foreign key from MySQL Workbench up vote 10 down vote favorite 1 I'm trying to synchronize schema changes from MySQL Workbench to my database. I'm getting the following error when it tries to create a foreign key: Executing SQL script in server ERROR: Error 1005: Can't create table 'tomato.#sql-2730_1b8' (errno: 121) Here's the statement it's trying to execute: ALTER TABLE `tomato`.`ing_allergy_ingredient` ADD CONSTRAINT `fk_ai_allergy` FOREIGN KEY (`allergy_id` ) REFERENCES `tomato`.`ing_allergy` (`allergy_id` ) ON http://dba.stackexchange.com/questions/425/error-creating-foreign-key-from-mysql-workbench DELETE NO ACTION ON UPDATE NO ACTION Any ideas what this error means? mysql mysql-workbench share|improve this question asked Jan 8 '11 at 20:54 BenV 2,46062537 add a comment| 1 Answer 1 active oldest votes up vote 11 down vote accepted You will get this message if you're trying to add a constraint with a name that's already used somewhere else. According to this post you can check your constraint like this: If the table you're trying to create includes a foreign key constraint, and you've provided your own name for that constraint, remember that it must be unique within the database. Run this query to see if that name is in use somewhere: SELECT constraint_name, table_name FROM information_schema.table_constraints WHERE constraint_type = 'FOREIGN KEY' AND table_schema = DATABASE() ORDER BY constraint_name; share|improve this answer answered Jan 8 '11 at 21:27 Am1rr3zA 9481010 The foreign key didn't show up in this query, but when I looked at the table there was an index there with the same name. I believe it's a bug with the synchronization in MySQL Workbench. I downloaded the latest version (5.2.31) and the problem is gone. –BenV Jan 8 '11 at 22:27 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a
set a foreign key If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register http://board.phpbuilder.com/showthread.php?10359413-RESOLVED-mysql-error-1005-errno-121-when-trying-to-set-a-foreign-key before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 9 of http://www.cornbio.com/mysql-error-1005-can-t-create-table-test-production-errno-121/ 9 Thread: [RESOLVED] mysql error 1005 errno 121 when trying to set a foreign key Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Search Thread Advanced mysql error Search Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 09-27-2008,01:32 PM #1 s0me0ne View Profile View Forum Posts Senior Member Join Date May 2003 Posts 121 [RESOLVED] mysql error 1005 errno 121 when trying to set a foreign key I'm trying to setup a table that has 2 foreign keys. I was able to set host_id as a Foreign Key, but mysql error code I cannot get site_id to be a foreign key in the table SITES_HOSTS. I get mysql error 1005 errno 121 I'm using the MySQL Query Browser when I'm doing this, because I'm not good enough to use the command line, but the app shows me its doing this ALTER TABLE `db_special`.`sites_hosts` ADD CONSTRAINT `site_id` FOREIGN KEY `site_id` (`site_id`) REFERENCES `sites` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT; Here are my tables Code: SITES +-------------+---------------------+------+-----+---------------------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | title | varchar(100) | NO | | | | | description | longtext | YES | | NULL | | | url | varchar(150) | YES | | NULL | | | status | tinyint(3) unsigned | NO | | | | | pubdate | timestamp | NO | | CURRENT_TIMESTAMP | | | updated | timestamp | NO | | 0000-00-00 00:00:00 | | | subtitle | varchar(100) | YES | | NULL | | | sitetype_id | int(10) unsigned | NO | MUL | | | +-------------+---------------------+------+-----+---------------------+----------------+ HOSTS +---------+---------------------+------+-----+-------------------+----------------+ | Field | Type | Null | Key |
worth many words, so here is my model : http://img517.imageshack.us/i/model1n.jpg/ I created "firm","intake" and "material" tables properly, but when the turn is "production" , I've got that error: ERROR 1005: Can't create table 'test.product Read more 2012-04-13 01:43 MySQL Error "1005: can't create table (errno: 150)" on ADD FOREIGN KEY I have two tables: CREATE TABLE pages ( id int(11) NOT NULL AUTO_INCREMENT, author_id int(10) unsigned NOT NULL, create_date int(11) DEFAULT NULL, publish_date int(11) DEFAULT NULL, archive_date int(11) DEFAULT NULL, publish_level enum('1','11','21') Read more 2015-04-19 04:01 MySQL Error 1005 Can't create table .frm errno 150 I am a MySQL newbie. I created 3 tables in a database called "link_development" using MySQL Administrator 1.9.1 and MySL Server 5.0.18 32bit Windows. I originally named the primary key field link_development.links.linkid, but Ruby prefers just using Read more 2013-11-27 23:39 MySQL Error 1005: Can't create table (errno 168) I am trying to convert MyIsam tables into Innodb using following query: ALTER TABLE `myDb`.`myTable` ENGINE=InnoDB And I get "Error 1005: Can't create table (errno 168)" and could not find out why is doing this. In my.ini I uncommented "innodb_file_p Read more 2015-03-28 01:44 MySQL Error #1005 - Can't create table I used workbench to create the SQL to create my database. For some of my tables though, I get the message #1005 - Can't create table './renosta1_matchupDB/Athletes.frm' (errno: 150). ANy help would be greatly appreciated! Here's the create table quer Read more 2013-01-09 19:26 MySQL ERROR 1005: Can't create table (errno: 30) Where can one find information on the "errno:" part of the error messages thrown by MySQL? I am getting the above error when trying to create a table. Read more 2013-05-29 11:12 MySQL ERROR 1005: Can't create table (errno: 150) 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 databas