admin管理员组

文章数量:1530925

2024年6月4日发(作者:)

sqlserver实验答案

【篇一:sqlserver2008实用教程实验参考答案(实验6)】

=txt>一、索引

当表中数据量很大时,合理建立索引,可以提高查询的效率。

1. 对yggl数据库的employees表中的departmentid列建立索引

create index em_d_ind on employees(departmentid)

2. 在employees表的name列和address列上建立复合索引

create index em_na_ind on employees(name,address)

3. 对departments表上的departmentname列建立唯一非聚集索引

create unique index de_n_ind on departments(departmentname)

4. 重建索引

alter index all on employees rebuild

5. 删除索引

drop index em_d_id on employees

一次删除多个索引

drop index _d_ind,_na_ind

6. 使用界面方式创建、删除索引

二、数据完整性

1. 创建一个表employees5,只含有employeeid、name、sex和education列。将

name设为主键,并对employeeid列进行unique约束。

验证主键约束和唯一约束。

create table employees5

(

)

employeeid char(6) not null, name char(10) not null primary key, sex bit,

education char(4) constraint uk_id unique(employeeid)

2. 删除上例中创建的unique约束,删除后再验证唯一约束。

本文标签: 建立约束实验创建删除