EXPLAIN 命令显示语句的执行计划。当我们使用 EXPLAIN ANALYZE 命令执行语句时,查询计划将包括每个表的实际行扫描计数。
EXPLAIN command displays the execution plan for a statement. When we execute a statement using EXPLAIN ANALYZE command, the query plan will include the actual row scan count for each table.
Syntax
Following is the generic syntax of the EXPLAIN command.
EXPLAIN { [ PLAN FOR ] | ANALYZE } { select | insert | update | delete | merge}
除了此语法,我们还可以使用 select,insert,delete 和 merge。
Along with this syntax we can use select, insert, delete, and merge.
Example
此示例说明了具有 ID 1 的客户的查询计划详细信息。
This example explains the query plan details of the customer with ID 1.
EXPLAIN SELECT * FROM CUSTOMER WHERE ID = 1;
The above command produces the following output −