4
I have a table that has a Unique field, I deleted a record of this table and now I want to insert it again, however Mysql generates the error: "Error Code: 1062. Duplicate entry '' for key '". How can I resolve this?
TABLE CREATE:
CREATE TABLE `bem` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`cpf` varchar(17) NOT NULL,
...
PRIMARY KEY (`id`),
UNIQUE KEY `cpf` (`cpf`)
) ENGINE=InnoDB AUTO_INCREMENT=1764 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
INSERT EXAMPLE:
INSERT INTO `bem` (cpf, ...)VALUES ('12312312312', ...);
Place create from table.
– rray
Pole the
CREATE TABLE
and also the query ofINSERT
what are you doing.– Thiago Lunardi
you have some column called
excluido
orativo
? pq basically Insert Cpf already exists in the table.– rray
The record was actually deleted, giving a select nothing returns.
– HHead26
Was the deletion actually physical (delete) ? Delete and select was done in the same user section ? which error was reported ?
– Motta
Yes was delete.
– HHead26
The error reported is : "Error Code: 1062. Duplicate entry '12312312312' for key 'cpf_UNIQUE'" . delete was made more than a month ago.
– HHead26
I would dump this table, create a new base and test again.
– rray
With dump works, but I don’t want to have to do this every time another error like this occurs.
– HHead26
This test is to know if table is not corrupted.
– rray
My friend, you better put the word out
CREATE TABLE
complete. Another thing, check if, when you generate theINSERT
dynamically, all required fields are actually being populated with values.– Marcio Jalber