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)