Mysql Duplicate Entry Error Code
Contents |
Connectors More MySQL.com Downloads Developer Zone Section Menu: Documentation Home MySQL 5.5 Reference Manual Preface and Legal Notices General Information Installing and Upgrading MySQL Tutorial MySQL Programs MySQL Server Administration Security Backup mysql error 1062 duplicate entry for key primary and Recovery Optimization Language Structure Globalization Data Types Functions and Operators SQL Statement
Mysql Error Code 1062
Syntax The InnoDB Storage Engine Alternative Storage Engines High Availability and Scalability Replication MySQL Cluster NDB 7.2 Partitioning Stored mysql error codes list Programs and Views INFORMATION_SCHEMA Tables MySQL Performance Schema Connectors and APIs Extending MySQL MySQL Enterprise Edition MySQL Workbench MySQL 5.5 Frequently Asked Questions Errors, Error Codes, and Common Problems Sources of
Duplicate Entry '1' For Key 'primary' Mysql
Error Information Types of Error Values Server Error Codes and Messages Client Error Codes and Messages Problems and Common Errors How to Determine What Is Causing a Problem Common Errors When Using MySQL Programs Access denied Can't connect to [local] MySQL server Lost connection to MySQL server Client does not support authentication protocol Password Fails When Entered Interactively Host 'host_name' is blocked Too duplicate entry for key 'primary' mysql many connections Out of memory MySQL server has gone away Packet Too Large Communication Errors and Aborted Connections The table is full Can't create/write to file Commands out of sync Ignoring user Table 'tbl_name' doesn't exist Can't initialize character set File Not Found and Similar Errors Table-Corruption Issues Administration-Related Issues Problems with File Permissions How to Reset the Root Password What to Do If MySQL Keeps Crashing How MySQL Handles a Full Disk Where MySQL Stores Temporary Files How to Protect or Change the MySQL Unix Socket File Time Zone Problems Query-Related Issues Case Sensitivity in String Searches Problems Using DATE Columns Problems with NULL Values Problems with Column Aliases Rollback Failure for Nontransactional Tables Deleting Rows from Related Tables Solving Problems with No Matching Rows Problems with Floating-Point Values Optimizer-Related Issues Table Definition-Related Issues Problems with ALTER TABLE TEMPORARY Table Problems Known Issues in MySQL Restrictions and Limits Indexes MySQL Glossary Related Documentation MySQL 5.5 Release Notes Download this Manual PDF (US Ltr) - 26.7Mb PDF (A4) - 26.7Mb PDF (RPM) - 25.8Mb EPUB - 6.7Mb HTML Download (TGZ) - 6.4Mb HTML Download (Zip) - 6.5Mb HTM
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
Mysql Error 1062 Duplicate Entry '0' For Key 'primary'
this site About Us Learn more about Stack Overflow the company Business
Mysql Sqlstate
Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask mysql errors and solutions 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 https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html up Error Code: 1062. Duplicate entry '1' for key 'PRIMARY' up vote 9 down vote favorite 5 I have a problem on this error message, when i try this: INSERT INTO `PROGETTO`.`UFFICIO-INFORMAZIONI` (`ID`, `viale`, `num_civico`, `data_apertura`, `data_chiusura`, `orario_apertura`, `orario_chiusura`, `telefono`, `mail`, `web`, `Nome-paese`, `Comune`) VALUES (1, 'Viale Cogel ', '120', '2012-05-21', '2012-09-30', '08:00', '23:30', '461801243', 'informazioni@bolzano.it', 'Bolzanoturismo.it', 'Bolzano', 'BZ') Error Code: 1062. Duplicate http://stackoverflow.com/questions/14628269/error-code-1062-duplicate-entry-1-for-key-primary entry '1' for key 'PRIMARY' I haven't auto_increment data, PLEASE HELP me! This is the table related, UFFICIO-INFORMAZIONI CREATE TABLE IF NOT EXISTS `PROGETTO`.`UFFICIO-INFORMAZIONI` ( `ID` INT(11) NOT NULL , `viale` VARCHAR(45) NULL , `num_civico` VARCHAR(5) NULL , `data_apertura` DATE NULL , `data_chiusura` DATE NULL , `orario_apertura` TIME NULL , `orario_chiusura` TIME NULL , `telefono` VARCHAR(15) NULL , `mail` VARCHAR(100) NULL , `web` VARCHAR(100) NULL , `Nome-paese` VARCHAR(45) NOT NULL , `Comune` CHAR(2) NOT NULL , PRIMARY KEY (`ID`) , INDEX `Nome_paese` (`Nome-paese` ASC) , INDEX `Comune` (`Comune` ASC) , CONSTRAINT `Nome_paese` FOREIGN KEY (`Nome-paese` ) REFERENCES `PROGETTO`.`PAESE` (`Nome-paese` ) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT `Comune` FOREIGN KEY (`Comune` ) REFERENCES `PROGETTO`.`PAESE` (`Comune` ) ON DELETE NO ACTION ON UPDATE CASCADE) ENGINE = InnoDB INSERT INTO INSERT INTO `PROGETTO`.`UFFICIO-INFORMAZIONI` (`ID`, `viale`, `num_civico`, `data_apertura`, `data_chiusura`, `orario_apertura`, `orario_chiusura`, `telefono`, `mail`, `web`, `Nome-paese`, `Comune`) VALUES (1, 'Viale Cogel ', '120', '2012-05-21', '2012-09-30', '08:00', '23:30', '461801243', 'informazioni@bolzano.it', 'Bolzanoturismo.it', 'Bolzano', 'BZ'); INSERT INTO `PROGETTO`.`UFFICIO-INFORMAZIONI` (`ID`, `viale`, `num_civico`, `data_apertura`, `data_chiusura`, `orario_apertura`, `orario_chiusura`, `telefono`, `mail`, `web`, `Nome-paese`, `Comune`) VALUES (2, 'Via Olmo', '45', '2012-05-01', '2012-09-30', '08:00', '23:30', '393495169301', 'informazioni@lech.it', 'Lechinforma
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 more about hiring developers or posting ads with http://stackoverflow.com/questions/13132535/mysql-duplicate-entry-error-even-though-there-is-no-duplicate-entry 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 minute: Sign up MySQL duplicate entry error even though there is no duplicate entry up vote 5 down vote favorite 1 I am using MySQL 5.1.56, MyISAM. My table looks like this: CREATE TABLE IF NOT EXISTS `my_table` ( `number` int(11) NOT NULL, `name` duplicate entry varchar(50) NOT NULL, `money` int(11) NOT NULL, PRIMARY KEY (`number`,`name`) ) ENGINE=MyISAM; It contains these two rows: INSERT INTO `my_table` (`number`, `name`, `money`) VALUES (1, 'S. Name', 150), (2, 'Another Name', 284); Now I am trying to insert another row: INSERT INTO `my_table` (`number`, `name`, `money`) VALUES (2, 'S. Name', 240); And MySQL just won't insert it while telling me this: #1062 - Duplicate entry '2-S. Name' for key 'PRIMARY' I really don't understand it. The primary key is on the first two columns for key 'primary' (both of them), so the row I am trying to insert HAS a unique primary key, doesn't it? I tried to repair the table, I tried to optimize the table, all to no avail. Also please note that I cannot change from MyISAM to InnoDB. Am I missing something or is this a bug of MySQL or MyISAM? Thanks. To summarize and point out where I think is the problem (even though there shouldn't be): Table has primary key on two columns. I am trying to insert a row with a new combination of values in these two columns, but value in column one is already in some row and value in column two is already in another row. But they are not anywhere combined, so I believe this is supposed to work and I am very confused to see that it doesn't. mysql primary-key mysql-error-1062 duplicates share|improve this question edited Oct 30 '12 at 4:32 asked Oct 30 '12 at 4:13 user1763581 1451314 Are those the exact schema and exact INSERTs? If not, we may be barking up the wrong trees! Please provide a reproducible test case. –Rick James Oct 8 at 5:24 add a comment| 10 Answers 10 active oldest votes up vote 9 down vote accepted Your code and schema are OK. You probably trying on previous version of table. http://sqlfiddle.com/#!2/9dc64/1/0 Your table even has no UNIQUE, so that error is impossible on that table. Backup data from that table, drop it and re-create. Mayb