sqlserver 索引的使用(创建、删除和更新)

创建表格student

create table student(
    sno int primary key,
    sname varchar(20) not null,
    sex int default 1
)

一、创建索引

1、创建非聚集索引

create index index_student_sno on student(sno)

2、创建复合索引

create index index_student_sno_sname on student(sno,sname)

3、创建唯一非聚集索引

create unique index index_student_sno on student(sno)

二、删除索引

drop index student.index_student_sno

三、更新索引

1、重命名索引

--更改索引名: index_student_sno改为 index_student_sno1
sp_rename 'student.index_student_sno','index_student_sno1','INDEX'
发布了34 篇原创文章 · 获赞 1 · 访问量 1946

猜你喜欢

转载自blog.csdn.net/qq_38974638/article/details/104778481
今日推荐