For an existing table, is it permissible to create a unique on a column that might have repeating values?
A unique index never has duplicate values.
You can prevent duplicate values in a field in an Access table by creating a unique index.
By any way, (even by modifying the table definition) can we have unique index on duplicated column??? in below case b1 is the column where there are duplicate rows, but I was asked if I can create a unique index? Answer is simple NO.
Unlike the PRIMARY KEY index, you can have more than one UNIQUE index per table. Another way to enforce the uniqueness of value in one or more columns is to use the UNIQUE constraint. When you create a UNIQUE constraint, MySQL creates a UNIQUE index behind the scenes.
No, it is not permissible.
The following SQL:
ALTER TABLE `table`
ADD UNIQUE (`column`)
Will generate the following error:
#1062 - Duplicate entry 'data' for key 'column'
You can identify duplicates using:
SELECT * FROM `table`
GROUP BY `column`
HAVING COUNT(`column`) > 1
After removing all of the duplicates, you can add the UNIQUE
constraint.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With