Code SnippetMySQL

MySQL unique index with multiple columns

In MySQL, If you have an existing table and you want to have unique index across multiple columns.
You can use the snippet below.

ALTER TABLE `prefix_counter` ADD UNIQUE `unique_prefix_counter`(`prefix`, `year`);