Duplicate Entry Mysql Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have mysql error duplicate entry replication Meta Discuss the workings and policies of this site About Us rails mysql error duplicate entry Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with mysql error duplicate entry for key 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 programmers, just mysql duplicate entry error code like you, helping each other. Join them; it only takes a minute: Sign up Error Code: 1062. Duplicate entry 'PRIMARY' up vote 1 down vote favorite So, my professor gave me tables to insert it in a database but when I execute his code, MySQL is constantly giving the Error Code: 1062. Here is the conflict
Mysql Error Duplicate Entry For Key 'primary'
tables and the inserts: TABLES CREATE TABLE FABRICANTES( COD_FABRICANTE integer NOT NULL, NOMBRE VARCHAR(15), PAIS VARCHAR(15), primary key (cod_fabricante) ); CREATE TABLE ARTICULOS( ARTICULO VARCHAR(20)NOT NULL, COD_FABRICANTE integer NOT NULL, PESO integer NOT NULL , CATEGORIA VARCHAR(10) NOT NULL, PRECIO_VENTA integer, PRECIO_COSTO integer, EXISTENCIAS integer, primary key (articulo,cod_fabricante), foreign key (cod_fabricante) references Fabricantes(cod_fabricante) ); INSERT INTO: INSERT INTO FABRICANTES VALUES(10,'CALVO', 'ESPAÑA'); INSERT INTO FABRICANTES VALUES(15,'LU', 'BELGICA'); INSERT INTO FABRICANTES VALUES(20,'BARILLA', 'ITALIA'); INSERT INTO FABRICANTES VALUES(25,'GALLO', 'ESPAÑA'); INSERT INTO FABRICANTES VALUES(30,'PRESIDENT', 'FRANCIA'); INSERT INTO ARTICULOS VALUES ('Macarrones',20, 1, 'Primera',100,98,120); INSERT INTO ARTICULOS VALUES ('Tallarines',20, 2, 'Primera',120,100,100); INSERT INTO ARTICULOS VALUES ('Tallarines',20, 1, 'Segunda',99,50,100); INSERT INTO ARTICULOS VALUES ('Macarrones',20, 1, 'Tercera',80,50,100); INSERT INTO ARTICULOS VALUES ('Atún',10, 3, 'Primera',200,150,220); INSERT INTO ARTICULOS VALUES ('Atún',10, 3, 'Segunda',150,100,220); INSERT INTO ARTICULOS VALUES ('Atún',10, 3, 'Tercera',100,50,220); INSERT INTO ARTICULOS VALUES ('Sardinillas',10, 1,'Primera',250,200,200); INSERT INTO ARTICULOS VALUES ('Sardinillas',10, 1,'Segunda',200,160,200); INSERT INTO ARTICULOS VALUES ('Sardinillas',10, 1,'Tercera',100,150,220); INSERT INTO ARTICULOS VALUES ('Mejillones',10, 1, 'Tercera',90,50,200); INSERT INTO ARTICULOS VALUES ('Mejillones',10, 1, 'Primera',200,150,300); INSERT INTO ARTICULOS VALU
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
Mysql Error Duplicate Entry '0' For Key 'primary'
Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation mysql error 1062 duplicate entry '0' for key 'primary' Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like mysql duplicate entry 0 for key 1 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. http://stackoverflow.com/questions/28702069/error-code-1062-duplicate-entry-primary My table looks like this: CREATE TABLE IF NOT EXISTS `my_table` ( `number` int(11) NOT NULL, `name` 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 http://stackoverflow.com/questions/13132535/mysql-duplicate-entry-error-even-though-there-is-no-duplicate-entry 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 (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 yesterday add a comment| 10 A
This happens in order for us to be able to identify the problem and fix it, and keep the data http://www.ducea.com/2008/02/13/mysql-skip-duplicate-replication-errors/ consistent 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 http://www.simplemachines.org/community/index.php?topic=538631.0 those 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 duplicate entry SLAVE; There 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 mysql error duplicate skipping those errors will 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 Infrastruc
This topic This board Entire Site Community Modifications Themes Wiki Mantis Select language: Albanian Arabic Bulgarian Catalan Chinese Simplified Chinese Traditional Croatian Czech Informal Czech Danish Dutch English British English Esperanto Estonian Finnish French Galician German Informal German Greek Hebrew Hungarian Indonesian Italian Japanese Kurdish Kurmanji Lithuanian Macedonian Malay Norwegian Persian Polish Portuguese Brazilian Portuguese Pt Romanian Russian Serbian Cyrillic Serbian Latin Slovak Slovenian Spanish Es Spanish Latin Swedish Thai Turkish Ukrainian Urdu Vietnamese News: Help SMF by rating it on HotScripts.com, The PHP Resource Index, alexa.com and Softaculous Home Help Search Login Register Advertisement: Simple Machines Community Forum » General Community » Scripting Help » Topic: MySQL script error #1062 - Duplicate entry '47104' for key 'PRIMARY' « previous next » Print Pages: [1] Go Down Author Topic: MySQL script error #1062 - Duplicate entry '47104' for key 'PRIMARY' (Read 3368 times) khigh Jr. Member Posts: 138 MySQL script error #1062 - Duplicate entry '47104' for key 'PRIMARY' « on: July 31, 2015, 08:02:36 PM » Hi all and thanks for looking. I'll try to explain this as succinctly as possible. I apologize if this isn't the right place, but I'm way over my head with the MySQLI'm using a crawler converter to try to salvage an administrator abandoned phpbb forum (which hopefully will be converted to SMF). It crawls the site and generates .sql scripts, which I then import into the db/table and it populates them. It's really working surprisingly well. I've imported all of my members and categories, but I keep crapping out on importing the topics. It's always the same error in the same place, too. I did a second crawl and generated a new script thinking a bit may have been corrupted somewhere in the transfer,but no - same exact error in the exact same place, and that's with the data slightly different (half dozen new topics).Here' s what I'm getting on import. This is all the same forum topic. The conversation is innocuous enough to make public, but I changed the users to "User_1", "User_2", and "User_3". Everything else is verbatim. I'm assuming the problem is shown in this bit. Sorry about the code tag, but there are "quotes" in there and a stright paste kind of blew it all up. You'll probably have to paste it somewhere to view it.Code: [Select][i][b]SQL query:[/b]
INSERT INTO phpbb_posts (post_id,topic_id,forum_id,poster_id,post_time,poster_ip,post_username,post_edit_time,post_ed