1、查看索引:mysql> show index from tblname;

2、利用索引查询:SELECT * FROM product WHERE ID > =(select id from product limit 866613, 1) limit 20

    或者

     SELECT * FROM product a JOIN (select id from product limit 866613, 20) b ON a.ID = b.id

3、创建单个索引和联合索引

   首先创建一个表:create table t1 (id int primary key,username varchar(20),password varchar(20));

    创建单个索引的语法:create index 索引名 on 表名(字段名)

    索引名一般是:表名_字段名

    给id创建索引:create index t1_id on t1(id);

    创建联合索引的语法:create index 索引名 on 表名(字段名1,字段名2)

    给username和password创建联合索引:create index t1_username_password on t1(username,password)

 

相关文章:

  • 2021-05-23
  • 2021-11-15
  • 2022-12-23
  • 2021-10-26
  • 2022-02-16
猜你喜欢
  • 2021-11-30
  • 2021-04-29
  • 2021-07-25
  • 2021-07-30
  • 2021-10-26
  • 2022-01-14
相关资源
相似解决方案