我的 MYSQL 表中有一个唯一键,我想添加到它。
UNIQUE KEY `user_id` (`user_id`,`account_id`)
我想添加另一个
UNIQUE KEY `user_id` (`user_id`,`account_id`,`pet_id`)
最佳答案
ALTER TABLE your_table
DROP INDEX user_id,
ADD UNIQUE KEY `user_id` (`user_id`,`account_id`,`pet_id`)
Note: You won't need the backticks around the column names if you're using mariadb on Linux - in fact it will throw an syntax error 1064/(42000)
关于mysql - 在mysql中一起更改唯一键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20116140/