I have a table say employee
The employee
table has few fields such as
`salary`
`name`
`age`
`designation`
Out of which only designation
is nullable. I can't make it NOT NULL as it is being used by existing code.
Is it possible to create a combined unique constraint for all the columns mentioned above ??
When I try creating a new unique constraint.
ALTER TABLE `employee` ADD CONSTRAINT `employee_constraint`
UNIQUE key (`salary`,`name`, `age`, `designation`);
It creates the constraint successfully but when I try to insert the duplicated combination of these records, it inserts successfully. Is there a better way to create the constraint and discard the duplicate combination of these columns?