I have two foreign keys in table:
userId
visitorId
Also field action
I want to add constraints on these three field, that userId + visitorId + action will be unique.
How to do that in Workbench, MYSQL?
You can create a unique constraint:
alter table t add constraint unq_t_userid_visitorid_action
unique (userid, visitorid, action);
You can also do this by creating a unique index:
create unique index unq_t_userid_visitorid_action on t(userid, visitorid, action);
You should be able to create an index through the Workbench GUI interface.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.