MySQL索引面试题

294 阅读1分钟
  1. 下面哪些语句会使用到索引,哪些索引起了作用?
CREATE TABLE t1 (
    id int unsigned NOT NULL auto_increment,
    a int unsigned NOT NULL DEFAULT 0,
    b int unsigned NOT NULL DEFAULT 0,
    c int unsigned NOT NULL DEFAULT 0,
    PRIMARY KEY(id),
    KEY abc (a, b, c) USING BTREE
);

(1). SELECT * FROM t1 WHERE a=3 AND b=5 AND c=4;

(2). SELECT * FROM t1 WHERE c=4 AND b=6 AND a=3;

(3). SELECT * FROM t1 WHERE a=3 AND c=7;

(4). SELECT * FROM t1 WHERE a=3 AND b>7 AND c=3;

(5). SELECT * FROM t1 WHERE b=3 AND c=4;

(6). SELECT * FROM t1 WHERE a>4 AND b=7 AND c=9;

(7). SELECT * FROM t1 WHERE a=3 ORDER BY b;

(8). SELECT * FROM t1 WHERE a=3 ORDER BY c;

(9). SELECT * FROM t1 WHERE b=3 ORDER BY a;

题目的详细讲解,欢迎关注 Go后端干货

Go,后端等技术干货分享,欢迎一起交流学习