Java教程

数据库第四章

本文主要是介绍数据库第四章,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

外连接

 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的索引

 

这篇关于数据库第四章的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!