Mysql Error 1005 Hy000 Errno 121
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss sql server error 121 the workings and policies of this site About Us Learn more errno 121 mysql about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow
Errno 121 Linux
Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping
Mysql Error No 150
each other. Join them; it only takes a minute: Sign up ERROR: Error 1005: Can't create table (errno: 121) up vote 81 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 is my first post i can't.. Below mysql error 1005 errno 150 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` -- ----------------------------------------------------- DROP TABLE IF EXISTS `Schedule` ; CREATE TABLE IF NOT EXISTS `Schedule` ( `lesson_id` VARCHA
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta
Mysql Rename Constraint
Discuss the workings and policies of this site About Us Learn windows error 121 more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us mysql error 150 Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like http://stackoverflow.com/questions/12623651/error-error-1005-cant-create-table-errno-121 you, helping each other. Join them; it only takes a minute: Sign up SQL - error code 1005 with error number 121 up vote 12 down vote favorite 4 I'm running the following MySQL script (trimmed down), generated automatically by MySQL Workbench and I get the following error: Error Code: 1005 Can't create table 'regula.reservation' (errno: 121) http://stackoverflow.com/questions/4412693/sql-error-code-1005-with-error-number-121 I'm not very proficient with databases and this error is not very informative. What is the problem here? -- ----------------------------------------------------- -- Table `regula`.`Users` -- ----------------------------------------------------- DROP TABLE IF EXISTS `regula`.`Users` ; CREATE TABLE IF NOT EXISTS `regula`.`Users` ( `idUsers` INT UNSIGNED NOT NULL AUTO_INCREMENT , `name` TEXT NOT NULL , `type` TEXT NOT NULL , `pwd` TEXT NOT NULL , PRIMARY KEY (`idUsers`) , UNIQUE INDEX `idUsers_UNIQUE` (`idUsers` ASC) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `regula`.`Projects` -- ----------------------------------------------------- DROP TABLE IF EXISTS `regula`.`Projects` ; CREATE TABLE IF NOT EXISTS `regula`.`Projects` ( `idProjects` INT UNSIGNED NOT NULL AUTO_INCREMENT , `ownerId` INT UNSIGNED NOT NULL , `name` TEXT NOT NULL , `date` DATE NOT NULL , `time` TIME NOT NULL , `place` TEXT NOT NULL , `itemType` INT NOT NULL , PRIMARY KEY (`idProjects`) , UNIQUE INDEX `idProjects_UNIQUE` (`idProjects` ASC) , INDEX `ownerId` (`ownerId` ASC) , CONSTRAINT `ownerId` FOREIGN KEY (`ownerId` ) REFERENCES `regula`.`Users` (`idUsers` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- -------------------------------------------------
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 http://stackoverflow.com/questions/14294561/sql-error-1005-cant-create-table-obl2-itemsubjects-errno-121 site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x http://board.phpbuilder.com/showthread.php?10359413-RESOLVED-mysql-error-1005-errno-121-when-trying-to-set-a-foreign-key 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 SQL : mysql error ERROR 1005: Can't create table 'obl2.itemsubjects' (errno: 121) up vote 5 down vote favorite 1 I have the following tables: CREATE TABLE `OBL2`.`item` ( `itemID` INT NOT NULL AUTO_INCREMENT , `itemName` VARCHAR(45) NOT NULL , PRIMARY KEY (`itemID`) , INDEX `itemName` (`itemName` ASC) ); CREATE TABLE `OBL2`.`subject` ( `subjectID` INT NOT NULL , `subjectName` VARCHAR(45) NOT NULL , PRIMARY KEY (`subjectID`) ); now since the mysql error 1005 connection is many to many . each item can have many subject and each subject can be related to many items - i'd like to set a connection table. this is my code: CREATE TABLE `OBL2`.`itemsubjects` ( `itemID` INT NOT NULL , `subjectID` INT NOT NULL , PRIMARY KEY (`itemID`, `subjectID`) , INDEX `itemID_idx` (`itemID` ASC) , INDEX `subjectID_idx` (`subjectID` ASC) , CONSTRAINT `itemID` FOREIGN KEY (`itemID` ) REFERENCES `OBL2`.`item` (`itemID` ) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `subjectID` FOREIGN KEY (`subjectID` ) REFERENCES `OBL2`.`subject` (`subjectID` ) ON DELETE CASCADE ON UPDATE CASCADE); but for some reason the code of the 3rd table is not being accepted. i get an error msg: ERROR 1005: Can't create table 'obl2.itemsubjects' (errno: 121) i've read about the error on the internet and it says it's a known issue of MYSQL yet there are no solutions. any thoughts? mysql sql table database-design create-table share|improve this question edited Jan 12 '13 at 15:14 Saharsh Shah 21.4k52356 asked Jan 12 '13 at 15:01 ronn jack 7639 Can you try to insert some data to first two table in the script and then add
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 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 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 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 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 | Default | Extra | +---------+---------------------+------+-----+-------------------