[MySQL] add a unique index by 2 columns

MySQL 對兩個欄位組合建立複合唯一索引的 ALTER TABLE 語法,防止相同欄位值組合的重複資料寫入。

ALTER TABLE table_name ADD UNIQUE INDEX(column1, column2);

comments powered by Disqus
Powered by Hugo. Theme Stack. All Rights Reserved.