6 综合型实验项目索引和数据完整性
(一)建立索引
1
、对
YGGL
数据库的
Employees
表中的
DepartmentID
列建立
索引。
create
index
ind_dep
on
Employees
(
DepartmentID
);
2
、
在
Employees
表的
Name
列和
Address
列上建立复合索引。
create
index
ind_Name_Add
on
Employees
(
Name
,
Address
);
3
、
对
Departments
表上的
DepartmentName
列建立唯一非聚集索
引。
create
unique
index
ind_depName
on
Departments
(
DepartmentName
);
(二)重建索引
1
、重建表
Employees
中的所有索引。
alter
index
all
on
Employees
rebuild
;
(三)删除索引。
1
、使用
DROP
INDEX
语句删除表
Employees
上的索引
Depart_ind
。
drop
index
ind_dep
on
Employees
;
2
、
使用
DROP INDEX
一次删除
Employees
表上的多个索引。
drop
index
Employees
.
ind_Name_Add
,
Employees
.
ind_depName
;
(四)数据完整性操作
1
、创建一个表
Employees5
,只含
EmployeesID
,
Name,Sex
和