How to add composite unique column to mysql table

I have a table:

  • user_id int Composite Unique (deal_id + user_id+deal_type) .
  • deal_id int
  • deal_type varchar .
  • created_on datetime .

This is my table. I want to create a composite unique column user_id so that one user can only have a unique deal_id for each deal_type .

How to make composite unique to in mysql phpmyadmin .

+4
source share
1 answer
 ALTER TABLE my_table ADD UNIQUE KEY (user_id, deal_type, deal_id); 
+9
source

Source: https://habr.com/ru/post/1439622/


All Articles