創建外鍵時的選項
drop table student;
drop table class;
drop table student_class;
Create table student(student_id integer not null
Create table class(class_id integer not null
Create table student_class(student_class_id integer
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
Insert into class(class_id
Insert into student_class(student_class_id
Restrict/no action/cascade/set null
From:http://tw.wingwit.com/Article/program/DB2/201311/21928.html