数据库创建索引

创建索引:(学生学号创建聚集索引)
create unique clustered index IX_student_ID on student(studentid)
规则:
create(unique)(clustered)(nonclustered)index 索引名 on 表名/视图名(索引列名,(asc/desc))
(with pad_index,fillfactor=填充因子值)drop_existing
unique 唯一索引
clustered 聚集索引
nonclustered 非聚集索引
asc 升序,desc降序
pad_index 每个索引页留出空间
fillfactor 该页面填充宽度
drop_existing 删除已存在同名索引
索引命名:IX_表名_列名
组合索引:
create unique clustered index IX_grade_studentid_courseid on grade(studentid,courseid)
查看索引:
exec sp_helpindex 表名
删除索引:
drop index 表名.索引名(视图.索引名)
drop index student.IX_student_Name
索引分析:
set showplan_All(on/off)
set showplan_text(on/off)
处理器执行每个语句采用步骤
setshowplan_All on go
select studentid,studentname,birthday from student as s inner join class as c
on s.classid=c.class id go
set showplan_All of go
花费磁盘活动量统计:
set statistics  IN on/off
同上
查看碎片:
DBCC showcontic(表名,表id,视图名,视图id,索引名,索引id)
DBCC showcontic(student)
维护重建索引:
(影响用户使用)

drop_existing
Alter index IX_student_classid(索引名/all)
on student(表名视图名)
reorganize
(不影响用户使用)
Alter index IX_class_classid
on class
rebuild
查看统计信息:
DBCC show_statistics(student,pk_student)(表名,索引名)
创建统计信息:
create statistics 统计信息名on表名视图名(列)
更新统计信息:
update statistics表名(统计信息名)
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值