EXPLAIN statement can be used in two ways.
First, you can use EXPLAIN table;
This gives very similar output to DESCRIBE table or SHOW COLUMNS FROM table.
The second and more interesting way you can use EXPLAIN allows you to see exactly how MySQL evaluates a SELECT query.
To use it this way, just put the word explain in front of a SELECT statement.
You can use the EXPLAIN statement when you are trying to get a complex query to work and clearly haven’t got it quite right, or when a query’s taking a lot longer to process than it should. If you are writing a complex query, you can check this in advance by running the EXPLAIN command before you actually run the query. With the output from this statement, you can rework your SQL to optimize it if necessary. It’s also a handy learning tool.
Example is:
explain select employid from employtable;
- Kiran's blog
- 285 reads













Post new comment