自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

教你快速掌握DB2數(shù)據(jù)庫創(chuàng)建外鍵時的選項

數(shù)據(jù)庫
DB2數(shù)據(jù)庫主要應(yīng)用于大型應(yīng)用系統(tǒng),具有較好的可伸縮性,可支持從大型機(jī)到單用戶環(huán)境,應(yīng)用于OS/2、Windows等平臺下, DB2數(shù)據(jù)庫提供了高層次的數(shù)據(jù)利用性、完整性、安全性、可恢復(fù)性,本文教你快速掌握DB2數(shù)據(jù)庫創(chuàng)建外鍵時的選項。

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

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

  drop table student;
  drop table class;
  drop table student_class;
  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 ;
  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 ;
  Create table student_class(student_class_id integer,student_id integer,class_id integer) in luzl_32k_tb index in luzl_32k_tb;
  alter table student_class add constraint if_class foreign key(class_id) references class(class_id) ON DELETE cascade ON UPDATE RESTRICT;
  alter table student_class add constraint if_student foreign key(student_id) references student(student_id) ON DELETE cascade ON UPDATE RESTRICT;
  Insert into student(student_id,student_name) values(1,'luzl');
  Insert into class(class_id,class_name) values(1,'db2');
  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選項指定的話,如果刪除父記錄,依賴于他的子記錄也會自動刪除.相當(dāng)于級聯(lián)刪除.如果指定no action和cascade都會報錯,因為還有子記錄所以無法刪除該記錄.set nul允許刪除父記錄并且l會將子表中與父表關(guān)聯(lián)的字段設(shè)置為null.

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

  4.另外還需要注意一點,父表中的字段必須是主鍵,才能做為子表的外鍵。

文中的介紹有一部分時以代碼的形式展現(xiàn)出來的,可能對與剛?cè)腴T的初學(xué)者來說比較難理解,本文為大家啊整理的條理比較明了,希望對大家寓所幫助。

【編輯推薦】

  1. 在IBM DB2數(shù)據(jù)庫中進(jìn)行包的重綁定
  2. 三種級別的DB2數(shù)據(jù)庫字符集的設(shè)置與修改
  3. DB2數(shù)據(jù)庫使用的14個經(jīng)典小技巧
責(zé)任編輯:迎迎 來源: 賽迪網(wǎng)
相關(guān)推薦

2010-08-19 09:44:04

DB2創(chuàng)建外鍵

2010-08-18 09:09:15

DB2創(chuàng)建外鍵

2010-08-20 08:37:59

DB2創(chuàng)建外鍵

2010-08-09 10:08:15

DB2 創(chuàng)建外鍵

2011-03-16 13:21:04

IBM DB2數(shù)據(jù)庫性能參數(shù)

2010-08-10 13:44:51

DB2創(chuàng)建外鍵

2010-11-03 16:32:10

DB2創(chuàng)建數(shù)據(jù)庫

2010-09-06 10:00:00

DB2數(shù)據(jù)庫

2010-08-09 13:08:45

DB2數(shù)據(jù)庫

2010-08-02 14:34:53

DB2數(shù)據(jù)移動

2010-07-30 15:37:53

使用DB2

2011-03-11 16:02:03

DB2數(shù)據(jù)庫安裝

2010-07-27 08:48:52

DB2數(shù)據(jù)庫優(yōu)化

2010-08-12 10:54:21

IBM DB2數(shù)據(jù)庫

2011-08-31 16:33:00

DB2

2010-09-30 10:20:55

創(chuàng)建DB2數(shù)據(jù)庫

2010-08-27 15:26:19

DB2數(shù)據(jù)庫創(chuàng)建

2010-08-26 11:48:30

DB2外連接交叉連接

2011-03-16 10:19:49

DB2數(shù)據(jù)庫常用語句

2011-03-16 10:12:14

DB2數(shù)據(jù)庫常用語句
點贊
收藏

51CTO技術(shù)棧公眾號