MySQL - Specify unique constraint for multiple columns
Specify unique constraint for multiple columns in MySQL
You have this table score
id | name | phone_number | subject | score | |
---|---|---|---|---|---|
1 | Anna | [email protected] | 0919392 | Math | 10 |
and you want id
, name
, email
and phone_number
unique:
ALTER TABLE `score` ADD UNIQUE `unique_index`(`name`, `email`, `phone_number`);
Need a good GUI Tool for MySQL? TablePlus is a modern, native tool with an elegant UI that allows you to simultaneously manage multiple databases such as MySQL, PostgreSQL, SQLite, Microsoft SQL Server and more.
Not on Mac? Download TablePlus for Windows.
On Linux? Download TablePlus for Linux
Need a quick edit on the go? Download TablePlus for iOS.