To add a unique constraint, you need to use two components:
ALTER TABLE
– to change the table schema and,
ADD UNIQUE
– to add the unique constraint.
You then can define your new unique key with the format 'name'('column1', 'column2'...)
So for your particular issue, you could use this command:
ALTER TABLE `votes` ADD UNIQUE `unique_index`(`user`, `email`, `address`);
Related Contents:
- How to properly create composite primary keys – MYSQL
- Create table variable in MySQL
- Mysql: Select rows from a table that are not in another
- Maximum number of records in a MySQL database table
- How to import a CSV file into a MySQL table
- Does MySQL ignore null values on unique constraints?
- MySQL > Table doesn’t exist. But it does (or it should)
- MySQL – Make an existing Field Unique
- Which is more efficient: Multiple MySQL tables or one large table?
- MySQL: ALTER IGNORE TABLE gives “Integrity constraint violation”
- Is there any reason to worry about the column order in a table?
- Defining Composite Key with Auto Increment in MySQL
- MySQL – Select from a list of numbers those without a counterpart in the id field of a table
- Inserting multiple rows in mysql
- Find duplicate records in MySQL
- How can I make SQL case sensitive string comparison on MySQL?
- Generate an integer sequence in MySQL
- MySQL foreign key constraints, cascade delete
- MySQL Cannot Add Foreign Key Constraint
- mysql Foreign key constraint is incorrectly formed error
- mysql update column with value from another table
- Swapping column values in MySQL
- MySQL : isn’t in GROUP BY
- What is the benefit of zerofill in MySQL?
- What does mysql error 1025 (HY000): Error on rename of ‘./foo’ (errorno: 150) mean?
- Subqueries with EXISTS vs IN – MySQL
- Using SQL to determine word count stats of a text field
- MySQL versus PDO [duplicate]
- MySQL Event Scheduler on a specific time everyday
- Amazon EC2, mysql aborting start because InnoDB: mmap (x bytes) failed; errno 12
- Cannot change column used in a foreign key constraint
- INTERSECT in MySQL
- Why can’t a text column have a default value in MySQL?
- Difference in MySQL JOIN vs LEFT JOIN
- How to remove leading and trailing whitespace in a MySQL field?
- How to prepend a string to a column value in MySQL?
- MySQL LEFT JOIN 3 tables
- SQL Group By with an Order By
- How to select only date from a DATETIME field in MySQL?
- Sorting by date & time in descending order?
- Does Order of Fields of Multi-Column Index in MySQL Matter
- Making changes to multiple records based on change of single record with SQL
- How to get the count of each distinct value in a column? [duplicate]
- MySQL INSERT INTO … VALUES and SELECT
- No Entity Framework provider found for ‘MySql.Data.MySqlClient’ ADO.NET provider
- Get difference in years between two dates in MySQL as an integer
- Returning query results in predefined order
- Meaning of “n:m” and “1:n” in database design
- How to force case sensitive table names?
- How do I make a MySQL database run completely in memory?