MYSQL索引

本文详细介绍了如何在SQL中创建和管理索引,包括使用CREATE INDEX和ALTER TABLE语句来创建不同类型的索引,如B树索引,并演示了如何通过SHOW INDEX查看现有索引,以及DROP INDEX和ALTER TABLE DROP PRIMARY KEY来删除索引。

创建索引:

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;``
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值