Пользователи таблицы -таблица Innodb, которая имеет единый идентификатор столбца первичного ключа . В этой таблице не определено никаких отношений, но другие таблицы используют столбец идентификатора в качестве иностранного ключа. Ошибка SQL в производстве, потому что пользователь администратора попытался обновить учетную запись пользователя. Я перегонял запрос до самой базовой версии, которая все еще создает ошибку: < /p>
Код: Выделить всё
UPDATE `users` SET `email` = 'name@example.com' where `id` = '12345'
Код: Выделить всё
SELECT id,email from `users` where email like '%name@example.com%'
< /code>
+-------+------------------+
| id | email |
+-------+------------------+
| 12345 | name@example.com |
+-------+------------------+
1 row in set (0.000 sec)
< /code>
There is only one record with this email address.
Yet, when I run that UPDATE query, I get the following error:
#1062 - Duplicate entry 'name@example.com' for key 'email'
< /code>
I can run the update query for any other id/email combination found in the table and the error does not occur. I'm not changing the email. The email is already in the table exactly how I am setting it with the update query.
How could there possibly be a duplicate?
Why does this only happen on this one specific record?
There are no special characters on in the real email, its all normal English letters. I even ran it through Unicode converter to ensure there weren't any funny characters causing this.
I also did an optimize table
Подробнее здесь: https://stackoverflow.com/questions/795 ... licate-whi