Cannot Create Table Error 121 Mysql
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might
Errno 121 Mysql Can't Create Table
have Meta Discuss the workings and policies of this site About mysql cannot create table errno 150 Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads error 121 mysql workbench with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million
Errno 121 Mysql Foreign Key
programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ERROR: Error 1005: Can't create table (errno: 121) up vote 80 down vote favorite 21 Im having troubles with forward engineering my MySQL database into WAMP server.. I was going to post an image of the schema but as this
1005 Can't Create Table Errno 121
is my first post i can't.. Below is the executed script.. use aquaticstar; 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'; -- ----------------------------------------------------- -- Table `Students` -- ----------------------------------------------------- DROP TABLE IF EXISTS `Students` ; CREATE TABLE IF NOT EXISTS `Students` ( `id` VARCHAR(10) NOT NULL , `studentName` VARCHAR(45) NOT NULL , `gender` CHAR NOT NULL , `birthDate` DATETIME NOT NULL , `mNo` VARCHAR(10) NOT NULL , `contactName` VARCHAR(45) NOT NULL , `contactEmail` VARCHAR(45) NOT NULL , `contactPhone` INT(10) NOT NULL , `startDate` DATETIME NOT NULL , `remarks` VARCHAR(200) NULL , PRIMARY KEY (`id`) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `Waiting List` -- ----------------------------------------------------- DROP TABLE IF EXISTS `Waiting List` ; CREATE TABLE IF NOT EXISTS `Waiting List` ( `wait_id` VARCHAR(5) NOT NULL , `name` VARCHAR(45) NULL , `contactName` VARCHAR(45) NULL , `contactPhone` INT(10) NULL , `contactEmail` VARCHAR(45) NULL , `status` CHAR NULL , `remarks` VARCHAR(200) NULL , PRIMARY KEY (`wait_id`) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `Schedule` -- ----------------------
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 mysql error code 1005 errno 150 more about Stack Overflow the company Business Learn more about hiring developers or posting
Mysql Error Code 1005. Can't Create Table (errno 150)
ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack errno 121 linux Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MySQL Foreign Key Can't create table error:121 up vote 0 down http://stackoverflow.com/questions/12623651/error-error-1005-cant-create-table-errno-121 vote favorite I've two tables CREATE TABLE `patient_doctor_decision` ( `id` bigint(50) NOT NULL, `help_entity_id` bigint(50) NOT NULL, `description` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) ); CREATE TABLE `help_entity` ( `id` bigint(50) NOT NULL AUTO_INCREMENT, `type` int(50) NOT NULL, `comments` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) ); Both tables already have a lot of data. I want to establish a FK relationship on patient_doctor_decision.help_entity_id field with help_entity.id field. ALTER http://stackoverflow.com/questions/14598948/mysql-foreign-key-cant-create-table-error121 TABLE `patient_doctor_decision` ADD CONSTRAINT `fk_help_entity` FOREIGN KEY (`help_entity_id`) REFERENCES `help_entity`(`id`); I've verified that foreign keys are valid and there is no foreign key which is not present in the referenced table as primary key. SELECT * FROM patient_doctor_decision d WHERE d.help_entity_id NOT IN ( SELECT id FROM help_entity); 0 rows are returned. But when I execute the Alter statement mentioned above, I get this error ERROR 1005: Can't create table 'mydb.#sql-57c_9' (errno: 121) Please suggest. mysql foreign-keys share|improve this question asked Jan 30 '13 at 7:46 Ali 1,86081738 Are both tables InnoDB? –Explosion Pills Jan 30 '13 at 7:49 Yes both are InnoDB –Ali Jan 30 '13 at 7:53 2 There's not already an fk_help_entity in the table? –Explosion Pills Jan 30 '13 at 7:57 Isn't it because you are using NOT IN? –user1121883 Jan 30 '13 at 8:00 Can i know after established relationship which type of result you wanted ? –Md. Maruf Hossain Jan 30 '13 at 8:02 | show 3 more comments 1 Answer 1 active oldest votes up vote 0 down vote Well, I didn't got the exact thing working but changing the foreign key constraint name worked for me. share|imp
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 http://dba.stackexchange.com/questions/33795/error-error-1005-cant-create-table-progetto-museo-errno-121 policies of 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 create table 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 the top ERROR: Error 1005: Can't create table 'progetto.museo' (errno: 121) up vote 1 down vote favorite I've found on the web that: You will get this message if you're trying to add can't create table a constraint with a name that's already used somewhere else and 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 BUT if you can see my script, many tables are created with the same name's INDEX... so what have i to change? (i've posted the first lines of the script to create the database, the file is much bigger) 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'; CREATE SCHEMA IF NOT EXISTS `PROGETTO` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ; USE `PROGETTO` ; -- ----------------------------------------------------- -- Table `PROGETTO`.`SETTORE` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PROGETTO`.`SETTORE` ( `Comune` CHAR NOT NULL , `superficie` INT(11) NULL , PRIMARY KEY (`Comune`) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `PROGETTO`.`PAESE` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `PROGETTO`.`PAESE` ( `Nome-paese` CHAR NOT NULL COMMENT 'Il nome del paese' , `Comune` CHAR NOT NULL COMMENT 'La provincia del paese' , `num_abitanti` INT(11)