Duplicate Entry Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the php duplicate entry error workings and policies of this site About Us Learn more about error creating shaded jar duplicate entry Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions mysql duplicate entry error code Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Error 1062 Duplicate Entry For Key Primary
Join them; it only takes a minute: Sign 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', error 1062 duplicate entry '0' for key 'primary' '2012-09-30', '08:00', '23:30', '461801243', 'informazioni@bolzano.it', 'Bolzanoturismo.it', 'Bolzano', 'BZ') Error Code: 1062. Duplicate 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 `PROG
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 error 1062 duplicate entry 'innodb' for key 'primary' Us Learn more about Stack Overflow the company Business Learn more about hiring
Error 1062 Duplicate Entry '1' For Key 'primary'
developers or posting ads with us Database Administrators Questions Tags Users Badges Unanswered Ask Question _ Database Administrators Stack Exchange is
Mysql Replication Duplicate Entry
a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute: Sign up Here's how http://stackoverflow.com/questions/14628269/error-code-1062-duplicate-entry-1-for-key-primary it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Add UNIQUE index fails with duplicate entry error, but no duplicates found up vote 1 down vote favorite Given table: CREATE TABLE mytable ( field_a CHAR(15) NOT NULL DEFAULT '', field_b MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, field_c SMALLINT UNSIGNED NOT NULL DEFAULT 0, field_d SMALLINT http://dba.stackexchange.com/questions/106294/add-unique-index-fails-with-duplicate-entry-error-but-no-duplicates-found UNSIGNED NOT NULL DEFAULT 0, field_e CHAR(1) NULL DEFAULT '', field_f SMALLINT UNSIGNED NOT NULL DEFAULT 0 ) ENGINE=MyISAM DEFAULT CHARACTER SET=UTF8 COLLATE utf8_general_ci; Required index: ALTER TABLE mytable ADD UNIQUE INDEX idx_key (field_a, field_b); Data size is about 51 Mio. rows. Following problem: Attempt 1: If I try to create the index after the data is in the table it fails with duplicate key error. A select on the failed key returns only one(!) row. [23000][1062] Duplicate entry 'aaaaaaaaaaaaaaa-11111' for key 'idx_key' SELECT COUNT(*) FROM mytable WHERE field_a='aaaaaaaaaaaaaaa' AND field_b='11111' returns 1 (!) Attempt 2: If I create the index on an empty table or make a combined private key and then put the data into the table, the table contains only 27 of 51 Mio. rows (!). Is there some kind of a limit on the unique index or a bug? I use MariaDB 10.0.20. Please help. Update 1 A count of unique rows SELECT COUNT(DISTINCT field_a,field_b) from mytable; returns 50 Mio rows. So there are about 1 Mio duplicates. This however does not explain the 27 Mio from attempt 2 or wrong exception from attempt 1. Update 2 the table used by the attempt 2: CREATE TAB
This happens in order for us to be able to identify the problem and fix it, and keep the data consistent http://www.ducea.com/2008/02/13/mysql-skip-duplicate-replication-errors/ with the mater that has sent the query. You can skip such errors, even if this is not recommended, as long as you know really well what are those https://github.com/akopytov/sysbench/issues/23 queries and why they are failing, etc. For example you can skip just one query that is hanging the slave using: 1 mysql>SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE; There duplicate entry might be cases where you will want to skip more queries. For example you might want to skip all duplicate errors you might be getting (output from show slave status;): 1 "1062 | Error 'Duplicate entry 'xyz' for key 1' on query. Default database: 'db'. Query: 'INSERT INTO ..." If you are sure that skipping those errors will error 1062 duplicate not bring your slave inconsistent and you want to skip them ALL, you would add to your my.cnf: 1 slave-skip-errors = 1062 As shown above in my example 1062 is the error you would want to skip, and from here we have: _ Error: 1062 SQLSTATE: 23000 (ER_DUP_ENTRY) Message: Duplicate entry ‘%s’ for key %d_ You can skip also other type of errors, but again don’t do this unless you understand very well what those queries are and what impact they have on your data: 1 slave-skip-errors=[err_code1,err_code2,...|all] and for the error codes you can see them all here … (you will see them in your _show slave statu_s; also). Posted by Marius Ducea Feb 13th, 2008 posted in: tips & tricks tagged with: mysql, tips Tweet « Linux Tips: find all files of a particular size Increase PHP memory limit » Comments Please enable JavaScript to view the comments powered by Disqus. About Me My name is Marius Ducea. I am an experienced Infrastructure Developer based in the SF Bay
Sign in Pricing Blog Support Search GitHub This repository Watch 63 Star 477 Fork 133 akopytov/sysbench Code Issues 11 Pull requests 1 Projects 0 Pulse Graphs New issue ALERT: Error 1062 Duplicate entry 'xxxx' for key 'PRIMARY' #23 Closed seanlook opened this Issue Mar 17, 2016 · 3 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 2 participants seanlook commented Mar 17, 2016 I use --oltp-skip-trx=on option to avoid BEGIN statement that will start one transaction because I need to do performance test in read-write spilt scenario. But when I set num-threads up to 12, errors ocur: ALERT: Error 1062 Duplicate entry '38262' for key 'PRIMARY' FATAL: failed to execute function `event': (null) My sysbench version: 0.5 Work statement: sysbench --mysql-host=mysql_host --mysql-port=mysql_port--mysql-user=ecuser --mysql-password=ecuser \ --test=/usr/share/doc/sysbench/tests/db/oltp.lua --report-interval=10 --rand-type=uniform --rand-init=on --max-requests=0 \ --mysql-db=dbtest1a --oltp_tables_count=5 --oltp-table-size=50000 --oltp-read-only=off --max-time=60 --oltp-skip-trx=on --num-threads=12 run And does this patch work: ignoreduplicates.patch ? THANK YOU! Owner akopytov commented Mar 17, 2016 Yes, with --oltp-skip-trx=on duplicate key errors are expected for the oltp.lua script, because nothing prevents multiple connections inserting and committing a row with the same key. Without that option each transaction is idempotent, because it inserts and then deletes a row with the same key. Looking at the patch, that would work, but it seems like your are looking at some fairly old code snapshot. The current source tree supports the --mysql-ignore-errors option that has been implemented for precisely this purpose. Can you try --mysql-ignore-errors=1042 on the current git HEAD? seanlook commented Mar 18, 2016 OK, --mysql-ignore-errors=1062 ignore the duplicate entry error successfully! Actualy, I have modified that patch to ignore this error, but --mysql-ignore-errors seems more general. This is the problem. Before this, I have tried ./bin/sysbench --test=oltp help and ./bin/sysbench --test=dir/oltp.lua to get help. No help text: PANIC: unprotected error in call to Lua API (cannot open oltp: No such file or directory) mysql-ignore-errors option should be mentioned. Owner akopytov commented Mar 18, 2016 Glad --mysql-ignore-errors works for you. But I agree, whil