直接创建联合索引。
例如下方为tbl_follow表添加关注联合索引,target_id和follower_id分别是被关注用户和关注用户的user_id,它们联合起来是不能重复的。
unique_follow是给这个联合索引取名。
ALTER TABLE `tbl_follow`
ADD UNIQUE INDEX `unique_follow` (`target_id`,`follower_id`) USING BTREE
直接创建联合索引。
例如下方为tbl_follow表添加关注联合索引,target_id和follower_id分别是被关注用户和关注用户的user_id,它们联合起来是不能重复的。
unique_follow是给这个联合索引取名。
ALTER TABLE `tbl_follow`
ADD UNIQUE INDEX `unique_follow` (`target_id`,`follower_id`) USING BTREE