資料庫第四章
阿新 • • 發佈:2021-11-21
select * from student natural join takes
實際上有三種外連線
-
左外連線
-
右外連線
-
全外連線
檢視
檢視定義
create view faculty as select ID, name, dept_name from instructor
create view physics_fall_2009 as
select course.couse_id, sec_id, building, room_number
from course, section
where course.course_id = section.course_id
and course.dept_name = 'Physicas'
and section.semeaster = 'Fall'
and section.year = '2009';
SQL查詢中使用檢視
select course_id
from physics_fall_2009
where building = 'Watson';
物化檢視
特定資料庫系統允許儲存檢視關係,但是他們保證:如果用於定義檢視的實際關係改變,檢視也跟著修改,這樣的檢視被稱為物化檢視
單個關係上的約束
-
not null
-
unique
-
check
建立索引
create index studentID_index on student(ID)
上述語句在student關係的屬性ID上建立了一個名為studentID_index的索引