Mysql復(fù)合主鍵和聯(lián)合主鍵的區(qū)別解析
復(fù)合主鍵:
create table index_test ( a int not null, b int not null, c int not null, d int null, primary key (c, a, b) );
即一個表的主鍵同時由多個字段共同組成,復(fù)合主鍵索引見【Mysql】復(fù)合主鍵的索引。
聯(lián)合主鍵:
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的聯(lián)合主鍵,就是個邏輯概念
到此這篇關(guān)于Mysql復(fù)合主鍵和聯(lián)合主鍵的區(qū)別的文章就介紹到這了,更多相關(guān)mysql復(fù)合主鍵和聯(lián)合主鍵內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Mysql數(shù)據(jù)庫索引面試題(程序員基礎(chǔ)技能)
索引是Mysql的一塊硬骨頭,但是對于程序猿來說又是十分重要的基礎(chǔ)技能。本文將從索引原理、索引設(shè)計(jì)原則方面闡述Mysql索引,相信通過本文的學(xué)習(xí)你將完美征服阿里面試官2021-05-05MySQL創(chuàng)建數(shù)據(jù)表并建立主外鍵關(guān)系詳解
這篇文章主要介紹了MySQL創(chuàng)建數(shù)據(jù)表并建立主外鍵關(guān)系詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2019-06-06mysql5.7 新增的json字段類型用法實(shí)例分析
這篇文章主要介紹了mysql5.7 新增的json字段類型用法,結(jié)合實(shí)例形式分析了mysql5.7 新增的json字段類型具體功能、使用方法及操作注意事項(xiàng),需要的朋友可以參考下2020-02-02MySQL select、insert、update批量操作語句代碼實(shí)例
這篇文章主要介紹了MySQL select、insert、update批量操作語句代碼實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2020-03-03