1.索引的作用

数据库对象

用于提高数据库检索的效率,对于where,group,order by条件中经常出现的字段,创建索引可以加快效率

缺点:如果对于大量的数据插入时效率可能会变低

2.索引的使用

如果有这么一张表:student(字段id,sex,name,age等)

(1)单一索引

--创建索引
create index idx_sex on student(sex);

select id,sex,name from student where sex = '男';

(2)复合索引

--创建索引
create index idx_sex_name on student(sex,name);

select id,sex,name from student where sex='' and name='王五'

(3)删除索引

drop index idx_sex;

相关文章:

  • 2022-12-23
  • 2021-09-23
  • 2021-11-19
  • 2021-09-28
  • 2021-12-22
  • 2021-09-26
猜你喜欢
  • 2022-12-23
  • 2021-09-20
  • 2021-11-13
  • 2021-06-28
  • 2021-06-08
相关资源
相似解决方案