数据库第四章
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的索引