mysql多列指定唯一约束

demo
如何为MySQL中的多列指定唯一约束?
MySQL SQL Server 拉丁的传说 2019-06-03 10:25:56
如何为MySQL中的多列指定唯一约束?
我有张桌子:
table votes (
id,
user,
email,
address,
primary key(id),);
现在我想让列用户,电子邮件,地址独一无二的(一起)
如何在MySQL中做到这一点?
当然这个例子就是.。举个例子。所以请不要担心语义学。

create table user_actions (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`passport_uid` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户passport_uid',
`cuid` varchar(128) NOT NULL DEFAULT '' COMMENT 'cuid',
`buss_id` bigint(20) unsigned NOT NULL DEFAULT '' COMMENT '店铺ID',
`uc_id` bigint(20) unsigned NOT NULL DEFAULT '' COMMENT 'ucid',
`action_type` tinyint(4) unsigned NOT NULL DEFAULT 1 COMMENT '1、页面浏览 2、留言咨询 3、拨打电话',
`action_info` varchar(1024) NOT NULL DEFAULT '' COMMENT '行为内容,如页面浏览的地址',
`create_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '更新时间',
primary key (`id`),
key `k_ucid` (`uc_id`),
key `k_bussid` (`buss_id`),
unique key `uk_uid_bussid_type` (`passport_uid`, `buss_id`, `action_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户行为表';
原文地址:https://www.cnblogs.com/djwhome/p/12721154.html