EXPLAIN statement MySQL

0
Your rating: None

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;

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.

Cumulus Tag Cloud

Kiran Says

I love work environment which is:

Informal yet professional
Demanding yet rewarding
Challenging yet inspiring
Mediocrity is not an option
Having fun is serious business
Making mistakes is human
Forgiveness is Company Policy

Travelling Sucks