mysql 多列唯一_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='用户行为表';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值