标签:
视图是虚拟表,主要用于方便使用和安全性,如:
在使用视图时需要注意:
创建视图的语法
create view view_detail as select g.id as gid, g.name as gname, c.id as cid, c.name as cname from grade g, corse c where g.id = c.gradeid go
create view view_report as select gid, count(1) as corseNum from view_detail group by gid go
索引是用于提高查询效率的技术,主要有主键索引(自动成为聚集索引)、唯一索引(不允许重复)、聚集索引(一张表只能有一个)、非聚集索引等
创建索引的语句
create nonclustered index idx_studentname on student (name) with fillfactor = 30
其中,fillfactor是填充因子,默认30%
显示指定索引的语句是:
select * from student with(index=idx_studentname) where name like ‘%s%‘
创建索引的一些指导原则:
标签:
原文地址:http://www.cnblogs.com/rammderek/p/4260547.html