UNIQUE index

If you want the index to be unique, you can specify the keyword UNIQUE. For example:

mysql> ALTER TABLE employees ADD UNIQUE INDEX unique_name (last_name, first_name);# There are few duplicate entries in employees database, the above statement is shown for illustration purpose only.

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.