How do I specify unique constraint for multiple columns in MySQL?

后端 未结 14 1995
庸人自扰
庸人自扰 2020-11-21 06:50

I have a table:

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

Now I want to make the columns user

14条回答
  •  借酒劲吻你
    2020-11-21 07:19

    this tutorial works for me

    ALTER TABLE table_name
    ADD CONSTRAINT constraint_name UNIQUE (column1, column2, ... column_n);
    

    https://www.mysqltutorial.org/mysql-unique-constraint/

提交回复
热议问题