文档详情

sql实验5(一).doc

发布:2017-12-13约1.42千字共8页下载文档
文本预览下载声明
实验报告专用纸 实验5 索引和视图 三、实验内容 1.分别使用企业管理器和Transact-SQL语句为studentsdb数据库的student_info和curriculum创建主键索引。 ①、使用企业管理器为studentsdb数据库的student_info创建主键索引。 ②使用企业管理器为studentsdb数据库的curriculum创建主键索引。(将课程表的课程编号属性设为主键,系统将自动创建主键索引) ③ 使用Transact-SQL语句为studentsdb数据库的student_info创建主键索引。(将先前创建好的主键移除) create clustered index student_info_idx on student_info(学号) ④ 使用Transact-SQL语句为studentsdb数据库的curriculum创建主键索引。(将先前创建好的主键移除) create clustered index curriculum_idx on curriculum(课程编号) 2.使用企业管理器按curriculum的课程编号列创建唯一性索引。 3.分别使用企业管理器和Transact-SQL语句为studentsdb数据库的grade表的“分数”字段创建一个非聚集索引,命名为grade_index ①使用企业管理器为studentsdb数据库的grade表的“分数”字段创建一个非聚集索引。 ②使用Transact-SQL语句为studentsdb数据库的grade表的“分数”字段创建一个非聚集索引。(删除之前所创建的索引) create nonclustered index grade_index on grade(分数) 4.为studentsdb数据库的grade表的“学号”和“课程编号”字段创建一个复合唯一索引,命名为grade_id_c_ind create unique index grade_id_c_ind on grade(学号,课程编号) 5.分别使用企业管理器和系统存储过程sp_helpindex查看《成绩表》和《学生表》上的索引信息。 ①使用SQL Server管理平台查看grade表和student_info表上的索引信息。 ②使用系统存储过程sp_helpindex查看grade表和student_info表上的索引信息。 Grade表索引信息: student_info表索引信息: 6.使用企业管理器的“向导”工具对grade表创建一个聚集索引和唯一索引。 使用系统存储过程sp_rename将索引grade_index更名为grade_ind sp_rename grade.grade_index,grade_ind,index 更名前: 更名后: 8.分别使用企业管理器和Transact-SQL语句DROP INDEX删除索引grade_ind再次使用系统存储过程sp_helpindex查看grade上的索引信息。 ①使用企业管理器删除索引grade_ind ②使用Transact-SQL语句DROP INDEX删除索引grade_ind drop index grade.grade_ind 成绩: 教师签名:_____________
显示全部
相似文档