WEB开发网
开发学院数据库MySQL 详解MySQL三项实用开发知识 阅读

详解MySQL三项实用开发知识

 2009-04-02 11:18:19 来源:WEB开发网   
核心提示: user是联合索引的名称,包含3个列,详解MySQL三项实用开发知识(3),分别是username,order,email,接下来执行以下sql

user是联合索引的名称,包含3个列,分别是username,order,email。接下来执行以下sql,使用explain命令来分析下运行结果。

代码:

mysql> explain select * from user where username='leehui';
+----+-------------+-------+------+---------------+------+---------+-------+------+--------+
| id | select_type | table | type | possible_keys | key  | key_len | ref   | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+-------+------+--------+
|  1 | SIMPLE| user  | ref  | user    | user | 152     | const |    1 | Using where |
+----+-------------+-------+------+---------------+------+---------+-------+------+--------+
1 row in set (0.00 sec)
 

mysql> explain select * from user where pws='123';
+----+-------------+-------+------+---------------+------+---------+------+------+---------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+---------+
|  1 | SIMPLE| user  | ALL  | NULL    | NULL | NULL    | NULL |    2 | Using where |
+----+-------------+-------+------+---------------+------+---------+------+------+---------+
1 row in set (0.00 sec)

上一页  1 2 3 4 5  下一页

Tags:详解 MySQL 实用

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接