
对于用户表
table_user { id, user_name, user_telephone, user_status } 其中 user_status:1,启用; 2, 禁用;-1,删除;
我想保证未删除的用户中,用户手机号是唯一的,该如何创建索引?
unique index (user_telephone, user_status) where user_status <> -1 ???
1 CRVV 2018 年 5 月 18 日 CREATE UNIQUE INDEX unique_user_idx ON table_user (user_telephone) WHERE user_status <> -1; |
2 corningsun OP |
3 RorschachZZZ 2018 年 5 月 18 日 @corningsun 请问是 mysql 吗? |
4 corningsun OP |
5 whx20202 2018 年 5 月 21 日 这个应该是部分索引,据我所知 mysql 没有,如果迁移可能需要留神 |