文章詳情頁
Mysql復合主鍵和聯合主鍵的區別解析
瀏覽:165日期:2023-05-05 10:12:05
復合主鍵:
create table index_test
(
a int not null,
b int not null,
c int not null,
d int null,
primary key (c, a, b)
);
即一個表的主鍵同時由多個字段共同組成,復合主鍵索引見【Mysql】復合主鍵的索引。
聯合主鍵:
create table index_test_a
(
id int not null,
a int not null
primary key (id)
);
create table index_test_b
(
id int not null,
b int not null
primary key (id)
);
create table index_test_a_b
(
id int not null,
a_id int not null,
b_id int not null,
primary key (id)
);
index_test_a_b表的id為表index_test_a和表index_test_b的聯合主鍵,就是個邏輯概念
到此這篇關于Mysql復合主鍵和聯合主鍵的區別的文章就介紹到這了,更多相關mysql復合主鍵和聯合主鍵內容請搜索以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持!
標簽:
MySQL
排行榜

網公網安備