假设MySQL数据库表:
create table T{k int unsigned not null auto_increment,a date,b varchar(24),c int,d varchar(24),primary key(k),unique key a_index (a DESC,b DESC),key k1(b),key k2(c),key k3(d));
如下哪些sql语句查询能较好的利用索引?()
正确答案: A D 你的答案: A B (错误)
select b from WHERE b like 'aaa%';
select a,b from T WHERE a='2015-10-25' ORDER BY b ASC,c ASC;
select a,b,c from T WHERE a='2015-10-25' ORDER BY b ASC;
select a,b,c from T WHERE a='2015-10-25' ORDER BY a,b;
BC由于索引是降序建立的,查询是升序,不适用。
D可以很好的利用索引,