日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
DB2創(chuàng)建外鍵時選項如何快速掌握?

此文章主要講述的是掌握DB2創(chuàng)建外鍵時選項的實際操作描述,你如果對快速掌握DB2創(chuàng)建外鍵時選項的實際操作描述有興趣的話你就可以點擊以下的文章進行觀看了,以下就是相關內(nèi)容的具體描述。

創(chuàng)新互聯(lián)是一家朝氣蓬勃的網(wǎng)站建設公司。公司專注于為企業(yè)提供信息化建設解決方案。從事網(wǎng)站開發(fā),網(wǎng)站制作,網(wǎng)站設計,網(wǎng)站模板,微信公眾號開發(fā),軟件開發(fā),成都小程序開發(fā),10余年建站對汽車玻璃修復等多個領域,擁有豐富設計經(jīng)驗。

創(chuàng)建外鍵時的選項:

1.創(chuàng)建測試表:

 
 
 
 
  1. drop table student;  
  2. drop table class;  
  3. drop table student_class;  
  4. Create table student(student_id integer not null,student_name varchar(200), CONSTRAINT P_KEY_1 primary key (student_id)) 
    in luzl_32k_tb index in luzl_32k_tb ;  
  5. Create table class(class_id integer not null,class_name varchar(200), CONSTRAINT P_KEY_2 primary key (class_id)) in luzl_32k_tb index in luzl_32k_tb ;  
  6. Create table student_class(student_class_id integer,student_id integer,class_id integer) in luzl_32k_tb index in luzl_32k_tb;  
  7. alter table student_class add constraint if_class foreign key(class_id) references class(class_id) ON DELETE cascade ON UPDATE RESTRICT;  
  8. alter table student_class add constraint if_student foreign key(student_id) references student(student_id) ON DELETE cascade ON UPDATE RESTRICT;  
  9. Insert into student(student_id,student_name) values(1,'luzl');  
  10. Insert into class(class_id,class_name) values(1,'db2');  
  11. Insert into student_class(student_class_id,student_id,class_id) values(1,1,1);  

 

2.On Delete 的選項有

Restrict/no action/cascade/set null.其中cascade選項指定的話,如果刪除父記錄,依賴于他的子記錄也會自動刪除.相當于級聯(lián)刪除.如果指定no action和cascade都會報錯,因為還有子記錄所以無法刪除該記錄.set nul允許刪除父記錄并且l會將子表中與父表關聯(lián)的字段設置為null.

3.On Update 只有兩個選項 no action/restrict.它們在更新和刪除時并沒有區(qū)別:如果與子表關聯(lián)不允許刪除.

4.另外還需要注意一點,父表中的字段必須是主鍵,才能做為子表的外鍵。以上的相關內(nèi)容就是對快速掌握DB2創(chuàng)建外鍵時的選項的介紹,望你能有所收獲。

以上的相關內(nèi)容就是對快速掌握DB2創(chuàng)建外鍵時的選項的介紹,望你能有所收獲。


網(wǎng)站名稱:DB2創(chuàng)建外鍵時選項如何快速掌握?
分享路徑:http://www.dlmjj.cn/article/dhsijoi.html