Mysql Error Number 121
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta mysql can't create table errno 121 Discuss the workings and policies of this site About Us Learn mysql error code 1005. can't create table (errno 150) more about Stack 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 of 6.2 million programmers, just like
Errno 121 Linux
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) errno 121 mysql 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
Windows Error 121
this site About Us Learn more about Stack Overflow the company Business mysql error no 150 Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask mysql rename constraint 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 http://stackoverflow.com/questions/4412693/sql-error-code-1005-with-error-number-121 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 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'; -- http://stackoverflow.com/questions/12623651/error-error-1005-cant-create-table-errno-121 ----------------------------------------------------- -- 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` VARCHAR(10) NOT NULL , `day` VARCHAR(3) NOT NULL , `branch` VARCHAR(30) NOT NULL , `level` VARCHAR(30) NOT NULL , `time` TIME NOT NULL , `ae` VARCHAR(45) NOT NULL , PRIMARY KEY (
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and http://stackoverflow.com/questions/12994919/can-not-create-table-in-workbench-errno-121 policies of this site About Us Learn more about Stack Overflow the company http://thenoyes.com/littlenoise/?p=81 Business Learn more about hiring developers or posting ads 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 6.2 million programmers, just like you, helping each other. Join them; it only takes a mysql error minute: Sign up Can not create table in Workbench, errno 121 up vote 6 down vote favorite 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'; CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ; USE `mydb` ; -- ----------------------------------------------------- -- Table `mydb`.`restaurants` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`restaurants` ( `id` INT NOT NULL AUTO_INCREMENT can't create table , `name` VARCHAR(128) NOT NULL , `description` VARCHAR(1024) NOT NULL , `address` VARCHAR(1024) NOT NULL , `phone` VARCHAR(16) NOT NULL , `url` VARCHAR(128) NOT NULL , `min_order` INT NOT NULL , `food_types` SET('pizza', 'sushi', 'osetian_pie') NOT NULL , PRIMARY KEY (`id`) , UNIQUE INDEX `name_UNIQUE` (`name` ASC) , UNIQUE INDEX `id_UNIQUE` (`id` ASC) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`regions` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`regions` ( `id` INT NOT NULL AUTO_INCREMENT , `restaurant` INT NOT NULL , `name` VARCHAR(128) NOT NULL , PRIMARY KEY (`id`) , INDEX `restaurant_idx` (`restaurant` ASC) , UNIQUE INDEX `id_UNIQUE` (`id` ASC) , CONSTRAINT `restaurant` FOREIGN KEY (`restaurant` ) REFERENCES `mydb`.`restaurants` (`id` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`food` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`food` ( `id` INT NOT NULL , `type` ENUM('pizza', 'sushi', 'osetian_pie') NOT NULL , `name` VARCHAR(45) NOT NULL , `ingredients` VARCHAR(256) NULL , `image` VARCHAR(256) NOT NULL , PRIMARY KEY (`id`) , UNIQUE INDEX `id_UNIQUE` (`id` ASC) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`food_variant` -- ---------------------------------------------------
perror 121 says this? MySQL error code 121: Duplicate key on write or update Really confused how you might get a duplicate key error while creating a table? 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; (If you're still on 4.1 or earlier, mysqldump --no-data yourDbName | grep CONSTRAINT to get a similar list) Thanks to [raymond] on Freenode. Share this:TweetMoreShare on TumblrPocket Filed under: MySQL FAQ Leave a comment Comments (14) Trackbacks (3) ( subscribe to comments on this post ) Álvaro G. VicarioApril 27th, 2010 - 11:20 In my case, it was an ALTER TABLE … ADD CONSTRAINT query and the name was in use by an index. JamesAugust 11th, 2010 - 12:48 Thank you very much. Worked like a charm. ArtemAugust 23rd, 2010 - 10:36 Thanks a lot! SenthilSeptember 4th, 2010 - 07:25 Great !! It worked. DUSMANTA SAHOONovember 20th, 2012 - 01:35 Thank you so much!!!! It worked ChandrababuDecember 1st, 2012 - 02:51 Thanks for post solution for ErrorNo:121, now my DB successfully executed, once again thanks to u… Furkan ÇakmakDecember 4th, 2012 - 05:30 Thank you very much. I have been tried so many things last two hours and I have fixed errors thanks to your note. JoshDecember 13th, 2012 - 21:34 Amazing. Thank you! From San Diego, Josh Per OlesenJanuary 6th, 2013 - 08:15 Awesomeness your way. Thanks! AshtonApril 1st, 2013 - 18:48 Me and my professor have been searching for 2 weeks on how to fix this problem and finally someone pulled through! -Thanks!! meApril 12th, 2013 - 02:08 You sir just saved my day. Thank you! VishaFebruary 5th, 2015 - 05:19 Worked WaqasApril 20th, 2015 - 00:12 Thank you Sir! cyreneFebruary 2nd, 2016 - 15:51 i think its poor that mySQL does not give a hint or a better error message regarding this. Leave a comment Cancel reply Name (required) Email (required) Website Notify me of follow-up comments by email. Notify me of new posts by email. Error creating foreign key from MySQL Workbench | CL-UAT Error creating foreign key from MySQL Workbench | XL-UAT MySQL -- Can't create table (errno: 121) -- Small Coder Blog Flour Power » « Err