mysql-error-1062

MySQL PHPMyAdmin Error #1062 - Duplicate entry '0' for key 'PRIMARY'

本秂侑毒 提交于 2020-01-15 05:17:07
问题 Now I want to add a primary key id column but it throws the error: #1062 - Duplicate entry '0' for key 'PRIMARY' I already tried this: Add primary key to existing table 回答1: When you creates a new column, a default value is asigned (in your case will be 0), so you need to specify wich values will it have (besides you can tell it to the column to be autoincremental, and it will do the work for you for the new entries of rows). You have to change all the values to be differents between them,

Which unique key is hit with my insert?

冷暖自知 提交于 2020-01-05 10:10:12
问题 Using MySQL, when I have a table with (for example) three keys (one primary, auto-increment, and two uniques on a column, eg. 'code' and 'name'), how can I (efficiently) know which uniqueness constraint was violated when doing an insert? You get an error #1062 - Duplicate entry 'Value' for key 2 , but how do I know key 2 is the key for the 'code' column and not the 'name' column? We develop this application with multiple developers, and I want to prevent the day we don't add the constraints

PHP MySQL INSERT fails due to unique constraint

岁酱吖の 提交于 2020-01-03 03:06:08
问题 On insert I am catching the unique constraint mysql_errno() 1062. This works fine but I want to find the existing row to re-instate or modify it. Is there are method to obtain the row id on insert fail? I tried mysql_insert_id() but realised that would only return the row I'm inserting (or failed to insert) therefore, I get 0. Is there no option but to issue another mysql_query and simply perform a select on the duplicate value? I just want to make sure there is no better, quicker, more

mySQL auto increment problem: Duplicate entry '4294967295' for key 1

耗尽温柔 提交于 2019-12-31 04:23:49
问题 I have a table of emails. The last record in there for an auto increment id is 3780, which is a legit record. Any new record I now insert is being inserted right there. However, in my logs I have the occasional: Query FAIL: INSERT INTO mail.messages (timestamp_queue) VALUES (:time); Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry '4294967295' for key 1 ) Somehow, the autoincrement jumped up to the INT max of 4294967295 Why on god's green earth would this get jumped up so high? I have

Magento — “SQLSTATE[23000]: Integrity constraint violation..” on customer update

一曲冷凌霜 提交于 2019-12-22 08:04:08
问题 After migrating servers, I'm getting an error every time I try to update customer information. I'm using a customer activation plugin, but after disabling it, I still get the same error. SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '7-127' for key 2 What is wrong? Even after uninstalling the plugin, I get this error while trying to save customer information. So this leads me to believe its a bigger problem with Magento and/or the server I'm switched to. I checked the

MySql can't make column auto_increment

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 10:15:11
问题 I have a table "Bestelling" with 4 columns: "Id" (PK), "KlantId", "Datum", "BestellingsTypeId", now I want to make the column Id auto_increment, however, when I try to do that, I get this error: ERROR 1062: ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1' for key 'PRIMARY' SQL Statement: ALTER TABLE `aafest`.`aafest_bestelling` CHANGE COLUMN `Id` `Id` INT(11) NOT NULL AUTO_INCREMENT ERROR: Error when running failback script. Details follow. ERROR 1046: No

MySQL ON DUPLICATE KEY insert into an audit or log table

冷暖自知 提交于 2019-12-18 04:16:07
问题 Is there a way to accomplish this? INSERT IGNORE INTO some_table (one,two,three) VALUES(1,2,3) ON DUPLICATE KEY (INSERT INTO audit_table VALUES(NOW(),'Duplicate key ignored') I really don't want to use PHP for this :( Thanks! 回答1: If you want to consider using a stored procedure, you can use a DECLARE CONTINUE HANDLER. Here's an example: CREATE TABLE users ( username VARCHAR(30), first_name VARCHAR(30), last_name VARCHAR(30), PRIMARY KEY (username) ); CREATE TABLE audit_table (timestamp

Converting mysql tables from latin1 to utf8

心已入冬 提交于 2019-12-17 22:19:39
问题 I'm trying to convert some mysql tables from latin1 to utf8. I'm using the following command, which seems to mostly work. ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; However, on one table I get an error about a duplicate key entry. This is caused by a unique index on a "name" field. It seems when converting to utf8, any "special" characters are indexed as their straight english equivalent. For example, there is already a record with a name field value of "Dru"

Error Code: 1062. Duplicate entry '1' for key 'PRIMARY'

情到浓时终转凉″ 提交于 2019-12-17 06:35:25
问题 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', '23:30', '461801243', 'informazioni@bolzano.it', 'Bolzanoturismo.it', 'Bolzano', 'BZ') Error Code: 1062. Duplicate entry '1' for key 'PRIMARY' I haven't auto_increment

Converting from 5.0.27 to 5.1.41, getting duplicate key errors (1062)

谁说胖子不能爱 提交于 2019-12-13 02:34:05
问题 I have a database that's currently running on a 5.0.27 server. I want to move to a new 5.1.41 server. I mysqldump'd all the files. When restoring, I get an error ERROR 1062 (23000) at line 21: Duplicate entry 'weiÃ' for key 'title' I've narrowed the failure down to this script, which I can run and it fails: -- -- Table structure for table `word` -- set names utf8; DROP TABLE IF EXISTS `word`; CREATE TABLE `word` ( `wordid` int (10) unsigned NOT NULL auto_increment, `title` char (50) NOT NULL