Mysql 主键(x,y)和主键(x)之间的SQL差异,唯一(y)
在SQL中,这两者之间有什么区别Mysql 主键(x,y)和主键(x)之间的SQL差异,唯一(y),mysql,sql,Mysql,Sql,在SQL中,这两者之间有什么区别 create table marriage ( person1 int not null references human on delete cascade, person2 int not null references human on delete cascade, primary key (person1, person2) ); 还有这个 create table marriage ( person1 int not
create table marriage (
person1 int not null references human on delete cascade,
person2 int not null references human on delete cascade,
primary key (person1, person2)
);
还有这个
create table marriage (
person1 int not null references human on delete cascade,
person2 int not null references human on delete cascade,
primary key (person1),
unique (person2)
);
有两个主键的表会阻止这种情况吗
marriage:
person1 | person2
1 2
2 1
第一个索引是两列上的唯一索引:这意味着两者的组合应该是唯一的。行1,2和2,1没有违反索引,因为索引将它们视为一个集合。1,2和1,3也不违反索引 第二个示例包含两个索引,它们都需要是唯一的。这意味着具有1,2和1,3的行违反了索引约束