蓝色字体是对MySQL表的连接(两表连接, 多表连接 )常见疑问的回答.
create table tt1(id int primary key, a1 INT, c1 INT, key
a1(a1));
create table tt2(id int primary key, a2 INT, c2 INT, key
a2(a2));
insert into tt1 values(1,1,1),(2,2,2),(3,3,3),(4,4,4);
insert into tt2 values(1,1,2),(2,2,2);
1)顺序扫描(全表扫描/ 局部扫描):
mysql> explain select c1 from tt1 where c1>0;
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key |
key_len | ref | rows |
Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE |
tt1 | ALL |
NULL | …
[获取更多]