更新时间:2023-10-23 15:08:22
添加另一个名为 isactive
之类的列.在 (username, isactive)
上创建唯一约束.
Add another column called something like isactive
. The create a unique constraint on (username, isactive)
.
然后您可以同时拥有活动和非活动用户名.您将无法拥有两个活动用户名.
Then you can have both an active and inactive user name at the same time. You will not be able to have two active user names.
如果您想要多个非活动名称,请使用 NULL
作为 isactive
的值.NULL
值可以在唯一索引中重复.
If you want multiple inactive names, use NULL
for the value of isactive
. NULL
values can be repeated in a unique index.