Explain an SQL statement

You can explain an SQL statement by various actions.

  • Entering the EXPLAIN command or pressing F18 (Explain) in any Thread Activity panel in either the SQL Statement and Package window or SQL Statement and DBRM window.

    The current SQL statement is then explained.

  • Selecting option 4 (Explain) from the Online Monitor Main Menu.

    The Explain Menu is displayed, where you can select one of four options for explaining an SQL statement.

  • Marking a range of lines to be explained from within an ISPF/PDF editor and issuing the EXPLAIN command from the editor command line.

    See ISPF Online Monitor Source Explain for more information.

The SQL statement is then explained and the result displayed in the Db2® Explain Output panel.

Figure 1 shows the flow of the Explain process.
Figure 1. Flow of Explain process
This figure is a graphical representation of the flow of the Explain process.

Selecting Explain from the Online Monitor Main Menu

You can access Explain by selecting option 4 (Explain) from the Online Monitor Main Menu. See Figure 1 for an example of the Online Monitor Main Menu.

The Explain Menu is displayed, where you can select one of four methods for specifying the SQL statement you want explained.

Explaining an SQL statement from an ISPF/PDF editor

You can explain an SQL statement that is imbedded in a source program or SPUFI input from an ISPF/PDF editor. To do this, specify a range of source lines to explain using the E line prefix command, then type EXPLAIN on the command line and press Enter. Any valid SQL statements within the specified range can then be selected from a list for Explain processing. For more information about source Explain, see ISPF Online Monitor Source Explain.

If Explain executed successfully, the Db2 Explain Output panel is displayed. For more information about the Db2 Explain Output panel, see Explain output (Db2 Explain Output panel).