问题

我有一张表:

table votes (
    id,
    user,
    email,
    address,
    primary key(id),
);

现在,我想让用户,电子邮件,地址列唯一(一起).

如何在MySql中执行此操作?

  • Of course the example is just... an example. So please don't worry about the semantics.


解决方法
ALTER TABLE `votes` ADD UNIQUE `unique_index`(`user`, `email`, `address`);



相关问题推荐