Duplicate Entry Error 1062
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta error 1062 duplicate entry for key primary Discuss the workings and policies of this site About Us Learn error 1062 duplicate entry '0' for key 'primary' more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack error 1062 duplicate entry 'innodb' for key 'primary' 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 like you,
Error 1062 Duplicate Entry '1' For Key 'primary'
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 tables and the mysql error 1062 duplicate entry '0' for key 'primary' 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 VALUES ('Macarrones',25, 1, 'Primera',90,68,150); INSERT INTO ARTICULOS VAL
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the 1062 duplicate entry magento workings and policies of this site About Us Learn more about Stack
Mysql Error 1062 Duplicate Entry For Key Primary
Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs
Duplicate Entry For Key 'primary' Mysql
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. Join http://stackoverflow.com/questions/28702069/error-code-1062-duplicate-entry-primary 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', '2012-09-30', '08:00', http://stackoverflow.com/questions/14628269/error-code-1062-duplicate-entry-1-for-key-primary '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 `PROGETTO`.`UFFICIO-INFORMAZIONI` (`ID`, `viale`, `num_civico`, `data_apertura`
here for a quick overview of the site Help Center Detailed answers http://stackoverflow.com/questions/28702069/error-code-1062-duplicate-entry-primary 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 http://www.webhostingtalk.com/showthread.php?t=1175401 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 duplicate entry Overflow Community Stack Overflow is a community of 4.7 million programmers, just 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 1062 duplicate entry but when I execute his code, MySQL is constantly giving the Error Code: 1062. Here is the conflict 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);
Forums Hosting Security and Technology How do I fix this mysql error #1062 - Duplicate entry for 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: How do I fix this mysql error #1062 - Duplicate entry for key Tweet Thread Tools Show Printable Version Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 07-21-2012,05:04 PM #1 critical mass View Profile View Forum Posts View Forum Threads Junior Guru Wannabe Join Date Apr 2011 Posts 38 How do I fix this mysql error #1062 - Duplicate entry for key See image below I am getting this error while trying to import a mysql database table after exporting from my remote db server to my local mysql server. I dont know exactly how this problem came about I only realised while trying to use the data locally, but I just cant get the data imported due to the error. Can anyone help? http://i45.tinypic.com/zy8t9y.png Attached Thumbnails Reply With Quote 0 07-21-2012,05:46 PM #2 Drxx View Profile View Forum Posts View Forum Threads Visit Homepage Premium Member Join Date May 2006 Location /boot Posts 88 Hi, try to import your db into new empty db on local server .. coz your db have already tables .. Or .. empty/drop tables into this db before import the new db.sql file Good Luck Reply With Quote 0 07-21-2012,10:31 PM #3 critical mass View Profile View Forum Posts View Forum Threads Junior Guru Wannabe Join Date Apr 2011 Posts 38 Thank you but Ive already tried this, this error was received by trying the import into a newly created db. What I would like to know is how to fix the duplicate key issue to get rid of the error so I can complete the import. Reply With Quote 0 07-21-2012,11:10 PM #4 foobic View Profile View Forum Posts View Forum Threads Retired Moderator Join Date Feb 2005 Location Australia Posts 5,842 Originally Posted by critical mass Thank you but Ive already tried this, this error was received by trying the import into a newly created db. What I would like to know is how to fix the duplicate key issue to get rid of the error so I can complete the import. So you're starting from an empty db and using the "CREATE TABLE" statements from the dump file? If so, try to narrow the problem down to a single statement - the one your screenie shows doesn't seem to correspond to the error message. Chris "Some problems are so complex that you have to be highly int