创建索引:
create index index_birth on student.stu(stuBirth desc) using btree;
create index index_idscore on student.score(stuID,score);
alter table stu add index index_birth(stuBirth desc);
alter table score add index index_idscore (stuID,score);
create table teacher (teaId int not null primary key,teaName varchar(30) not null,teaSchool varchar(50) not null,index index_name (teaName(3)));
create table teacher (teaId int not null ,teaName varchar(30) not null,teaSchool varchar(50) not null,index index_nane (teaName(3)),primary key(teaID));
查看索引:
show index from stu from student;
show index from teacher from student;
删除索引:
drop index index_name on teacher;
alter table teacher drop primary key;``
本文详细介绍了如何在SQL中创建和管理索引,包括使用CREATE INDEX和ALTER TABLE语句来创建不同类型的索引,如B树索引,并演示了如何通过SHOW INDEX查看现有索引,以及DROP INDEX和ALTER TABLE DROP PRIMARY KEY来删除索引。
362

被折叠的 条评论
为什么被折叠?



