使用MySQL EXPLAIN关键字获取信息?
让我们首先创建一个表-
mysql> create table DemoTable1541 -> ( -> EmployeeId int, -> EmployeeFirstName varchar(20) NOT NULL -> );
这是在列上创建索引的查询-
mysql> create index emp_name_index on DemoTable1541(EmployeeFirstName); Records: 0 Duplicates: 0 Warnings: 0
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable1541 values(1,'Robert'); mysql> insert into DemoTable1541 values(2,'Adam'); mysql> insert into DemoTable1541 values(3,'Mike');
使用select语句显示表中的所有记录-
mysql> select * from DemoTable1541;
这将产生以下输出-
+------------+-------------------+ | EmployeeId | EmployeeFirstName | +------------+-------------------+ | 1 | Robert | | 2 | Adam | | 3 | Mike | +------------+-------------------+ 3 rows in set (0.00 sec)
以下是使用EXPLAIN的查询-
mysql> explain select * from DemoTable1541 where EmployeeFirstName='Mike';
这将产生以下输出-
+----+-------------+---------------+------------+------+----------------+----------------+---------+-------+------+----------+-------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+---------------+------------+------+----------------+----------------+---------+-------+------+----------+-------+ | 1 | SIMPLE | DemoTable1541 | NULL | ref | emp_name_index | emp_name_index | 62 | const | 1 | 100.00 | NULL | +----+-------------+---------------+------------+------+----------------+----------------+---------+-------+------+----------+-------+ 1 row in set, 1 warning (0.00 sec)
热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短