Error Code: 1062. Duplicate entry '1' for key 'PRIMARY'
The main reason why the error has been generated is because there is already an existing value of 1
for the column ID
in which you define it as PRIMARY KEY
(values are unique) in the table you are inserting.
Why not set the column ID
as AUTO_INCREMENT
?
CREATE TABLE IF NOT EXISTS `PROGETTO`.`UFFICIO-INFORMAZIONI` (
`ID` INT(11) NOT NULL AUTO_INCREMENT,
`viale` VARCHAR(45) NULL ,
.....
and when you are inserting record, you can now skip the column ID
INSERT INTO `PROGETTO`.`UFFICIO-INFORMAZIONI` (`viale`, `num_civico`, ...)
VALUES ('Viale Cogel ', '120', ...)
If you are using PHPMyAdmin You can be solved this issue by doing this:
CAUTION: Don't use this solution if you want to maintain existing records in your table.
Step 1: Select database export method to custom:
Step 2: Please make sure to check truncate table before insert in data creation options:
Now you are able to import this database successfully.