MYSQLÖÐEXPLAINµÄ˵Ã÷
mysql> explain select count(id) from t_prehandle_zhigao_05 as zhigao where start_time > '2008-05-30';
+----+-------------+--------+-------+---------------+------------+---------+------+---------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------+-------+---------------+------------+---------+------+---------+--------------------------+
| 1 | SIMPLE | zhigao | range | start_time | start_time | 8 | NULL | 1061762 | Using where; Using index |
+----+-------------+--------+-------+---------------+------------+---------+------+---------+--------------------------+
1 row in set (0.00 sec)
mysql>
EXPLAINÁеĽâÊÍ£º
table£ºÏÔʾÕâÒ»ÐеÄÊý¾ÝÊǹØÓÚÄÄÕűíµÄ
type£ºÕâÊÇÖØÒªµÄÁУ¬ÏÔʾÁ¬½ÓʹÓÃÁ˺ÎÖÖÀàÐÍ¡£´Ó×îºÃµ½×î²îµÄÁ¬½ÓÀàÐÍΪconst¡¢eq_reg¡¢ref¡¢range¡¢indexheºÍALL
possible_keys£ºÏÔʾ¿ÉÄÜÓ¦ÓÃÔÚÕâÕűíÖеÄË÷Òý¡£Èç¹ûΪ¿Õ£¬Ã»ÓпÉÄܵÄË÷Òý¡£¿ÉÒÔΪÏà¹ØµÄÓò´ÓWHEREÓï¾äÖÐÑ¡ÔñÒ»¸öºÏÊʵÄÓï¾ä
key£ºÊµ¼ÊʹÓõÄË÷Òý¡£Èç¹ûΪNULL£¬ÔòûÓÐʹÓÃË÷Òý¡£ºÜÉÙµÄÇé¿öÏ£¬MYSQL»áÑ¡ÔñÓÅ»¯²»×ãµÄË÷Òý¡£ÕâÖÖÇé¿öÏ£¬¿ÉÒÔÔÚSELECTÓï¾ä
ÖÐʹÓÃUSE INDEX£¨indexname£©À´Ç¿ÖÆʹÓÃÒ»¸öË÷Òý»òÕßÓÃIGNORE INDEX£¨indexname£©À´Ç¿ÖÆMYSQLºöÂÔË÷Òý
key_len£ºÊ¹ÓõÄË÷ÒýµÄ³¤¶È¡£ÔÚ²»Ëðʧ¾«È·ÐÔµÄÇé¿öÏ£¬³¤¶ÈÔ½¶ÌÔ½ºÃ
ref£ºÏÔʾË÷ÒýµÄÄÄÒ»Áб»Ê¹ÓÃÁË£¬Èç¹û¿ÉÄܵĻ°£¬ÊÇÒ»¸ö³£Êý
rows£ºMYSQLÈÏΪ±ØÐë¼ì²éµÄÓÃÀ´·µ»ØÇëÇóÊý¾ÝµÄÐÐÊý
Extra£º¹ØÓÚMYSQLÈçºÎ½âÎö²éѯµÄ¶îÍâÐÅÏ¢¡£½«ÔÚ±í4.3ÖÐÌÖÂÛ£¬µ«ÕâÀï¿ÉÒÔ¿´µ½µÄ»µµÄÀý×ÓÊÇUsing temporaryºÍUsing filesort£¬Òâ˼MYSQL¸ù±¾²»ÄÜʹÓÃË÷Òý£¬½á¹ûÊǼìË÷»áºÜÂý
extraÁзµ»ØµÄÃèÊöµÄÒâÒå
Distinct:Ò»µ©MYSQLÕÒµ½ÁËÓëÐÐÏàÁªºÏÆ¥ÅäµÄÐУ¬¾Í²»ÔÙËÑË÷ÁË
Not exists: MYSQLÓÅ»¯ÁËLEFT JOIN£¬Ò»µ©ËüÕÒµ½ÁËÆ¥ÅäLEFT JOIN±ê×¼µÄÐУ¬¾Í²»ÔÙËÑË÷ÁË
Range checked for each Record£¨i
Ïà¹ØÎĵµ£º
ÔÚmysqlÖÐÀûÓÃselectÓï¾äµÄÒ»¸öÌØÐԾͿÉÒԺܷ½±ãµØʵÏÖ²éѯ½á¹ûµÄ·ÖÒ³£¬selectÓï¾äµÄÓï·¨£º
SELECT [STRAIGHT_JOIN] [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [HIGH_PRIORITY]
[DISTINCT | DISTINCTROW | ALL]
select_expression,...
[INTO OUTFILE 'file_name'&nb ......
ת×Ô http://www.supidea.com/post/mysql_design_database.aspx
MySQLÊý¾Ý¿âÉè¼ÆÔÔò
MySQL¶ÔÓÚ³ÉΪһ¸ö·Ç³£¿ìËÙµÄÊý¾Ý¿â·þÎñÆ÷ÓÐ×ŵ±Ö®ÎÞÀ¢µÄÃûÉù£¬ËüÒ²·Ç³£ÈÝÒ×ÉèÖúÍʹÓá£Ëæ×ÅËü×÷ΪÍøÕ¾ºó¶ËÊý¾Ý¿âµÃÉùÍûÈÕÔö£¬ÆäЧ¹ûÔÚÈ¥Ä꿪ʼÓÐÃ÷ ÏÔÌá¸ß¡£µ«ÊǺܶàMySQLÓû§¸ü¶àµØÖªµÀÈçºÎ´´½¨Ò»¸öÊý¾Ý¿â²¢±àд¶ÔËüµÄ²éѯ¡£¾ÍÏñ³ÉÇ ......
Êý¾Ý¿â±íµ¥µÄ´´½¨
mysql> create database shuishengmu;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql & ......