zoukankan      html  css  js  c++  java
  • 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='用户行为表';
    
  • 相关阅读:
    CentOS 6.5下Git服务器搭建
    汉化Eclipse+配色方法(官方语言包)
    Cocos2d-x内存管理研究<二>
    PHP模板解析类实例
    smarty的ASSIGN()函数
    详解 $_SERVER 函数中QUERY_STRING和REQUEST_URI区别
    phpstorm 格式化代码方法
    php get_magic_quotes_gpc()函数用法介绍
    php示例代码
    MySQL数据类型:SQL_MODE设置不容忽视
  • 原文地址:https://www.cnblogs.com/djwhome/p/12721154.html
Copyright © 2011-2022 走看看