Existing problems:
When importing TXT file into Mysql database, ERROR 1062(23000) always appears: Duplicate entry ‘0’ for key ‘PRIMARY’ ERROR, but TXT file does not have a data with ID (PRIMARY key) of 0.
Reason for error:
This is still not clear, because I have no record of ID=0, so I don’t know why the duplicate ID is 0. At first, I thought it was the data encoding that caused the data chaos, but later I found that even the same encoding could not solve the problem.
Solutions:
Setting the primary key (ID) to AI (Auto Incremental) is sufficient. Setup has been completed and import has been successful
Note:
I thought that if I set the primary key to AI, the primary key column would be 1, 2, 3… , because the primary key in TXT file is discontinuous, but I found that this understanding is wrong, after insertion, the primary key still maintains its discontinuity.
When importing TXT file into Mysql database, ERROR 1062(23000) always appears: Duplicate entry ‘0’ for key ‘PRIMARY’ ERROR, but TXT file does not have a data with ID (PRIMARY key) of 0.
Reason for error:
This is still not clear, because I have no record of ID=0, so I don’t know why the duplicate ID is 0. At first, I thought it was the data encoding that caused the data chaos, but later I found that even the same encoding could not solve the problem.
Solutions:
Setting the primary key (ID) to AI (Auto Incremental) is sufficient. Setup has been completed and import has been successful
Note:
I thought that if I set the primary key to AI, the primary key column would be 1, 2, 3… , because the primary key in TXT file is discontinuous, but I found that this understanding is wrong, after insertion, the primary key still maintains its discontinuity.
Read More:
- The solution of duplicate entry ‘for key’ primary ‘when inserting data in MySQL
- Duplicate entry ‘787192513’ for key ‘primary’
- Solution of duplicate entry ‘value’ for key ‘field name’ in MySQL
- sqoop-import ERROR tool.ImportTool: Import failed: No primary key could be found for table user_info
- [reprint and save] MySQL does not set the primary key and uses the self growing ID method
- mysql Error Code: 1022. Can’t write; duplicate key in table `xxx`
- E11000 duplicate key error collection in mongodb
- Dbsql occurs when configuring SAP ATC during SCI check_DUPLICATE_KEY_ERROR
- MySQL creates tables and sets auto increment of primary keys
- MySQL failed to add foreign key: SQL 1452 cannot add or update a child row:a foreign key constraint fails
- pymongo.errors.DuplicateKeyError: E11000 duplicate key error collection: anjuke.ershoufang index
- Lambda set to map duplicate key error solution
- Mongoose Error: e11000 duplicate key error collection, code: 11000
- Golang MySQL error SQL: unknown driver “MySQL” (Forgotten import?) solution
- [Python CONDA error] cache entry design failed, entry ignored error resolution
- MySQL error 1451 23000 foreign key exception handling
- MySql ERROR CODE:1215 Cannot add the foreign key constraint
- MySQL failed to add foreign key error 1452
- Export and import method of MySQL under Linux