The first SQL sentence: You added a table column to the unionid table, and it is a non-empty string, so the initial value is an empty string '';
Second SQL sentence: You establish a unique constraint on the table column of the unionid table, but the premise of the unique constraint is that the values of the unionid column are not repeated. However, all values of the unionid column are null characters. string '', so it will report Duplicate entry '' for key 'unionid'.
Solution: First correct the value of unionid to be non-repeating and then add a unique constraint to the column.
The first SQL sentence: You added a
table
column to theunionid
table, and it is a non-empty string, so the initial value is an empty string''
;Second SQL sentence: You establish a unique constraint on the
table
column of theunionid
table, but the premise of the unique constraint is that the values of theunionid
column are not repeated. However, all values of theunionid
column are null characters. string''
, so it will reportDuplicate entry '' for key 'unionid'
.Solution: First correct the value of
unionid
to be non-repeating and then add a unique constraint to the column.Go directly to the database to operate. When you add an index, there will be a command prompt, so you will know what is wrong