mysql中的解释命令 [英] explain command in mysql

查看:38
本文介绍了mysql中的解释命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对mysql很陌生,我遇到了一个叫做explain tody的关键字,谁能帮我解释一下mysql中的explain关键字是什么?以及它是如何使用的?在什么情况下?

I am quite new to mysql, I came across a keyword called explain tody, can anyone help me explaining what is explain keywords in mysql? and how it is used? in what case?

如果有人可以向我展示示例会更好,任何帮助将不胜感激!

if anyone could show me examples will be even better, any help will be greatly appreciated!

假设我有以下 mysql 表:

suppose I have the following mysql table:

create table user
 (
   id unsigned int auto_increment primary key,
   user varchar(15) not null
 )

推荐答案

基本上解释用于向您提供有关数据库如何使用您指定的查询获取数据的信息.通常,如果您要分析一个缓慢的查询,您会使用它.

Basically explain is used to give you information regarding how the database goes about getting data using a query you specified. Typically you would use it if you have a slow query that you want to analyze.

据我所知,解释实际上只适用于进行数据检索的语句.所以,假设你的 create 语句中的表存在,一个更好的例子是......

As far as I know, explains really only apply to statements that are doing data retrieval. So, assuming the table in your create statement exists, a better example would be...

explain select * from user where user='steve'

您将从这里得到一个表格,其中包含有关如何检索数据的一些信息,而不是数据本身.在现实世界中,您可能只会将解释用于更复杂的查询.

What you'll get back from this is a table containing some information on how the data was retrieved, not the data itself. In the real world you would probably only use explains with much more complicated queries.

你应该尝试谷歌搜索mysql解释",它会产生一些很好的结果,解释你在运行解释查询时将得到的数据.例如,这里的信息似乎很不错.

You should try Googling "mysql explain", it turns up some pretty good results that explain the data you will get back when you run an explain query. For example, the information here seems pretty good.

这篇关于mysql中的解释命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆