DB2 Version 9.7 for Linux, UNIX, and Windows

Executing commands and SQL statements using the Command Editor

Use the Commands page of the Command Editor to execute commands and SQL statements.

About this task

The Command Editor is a notebook with a page for entering commands and pages for retrieving results. The appearance of this notebook changes depending on the target for your commands.

Procedure

To execute commands and SQL statements:

  1. Select the target on which you want to execute the commands or SQL statements. A target can be any DB2® database for Linux, UNIX, and Windows, z/OS® and OS/390® system or subsystem, or IMSplex that you can connect to. Targets that currently have connections or have had connections during the current session are listed in the Target drop-down list. If your target is not listed, click Add and select a target from those available on the Specify Target window.
  2. In the top pane, type the commands or SQL statements that you want to execute.

    You can select commands and statements previously executed in this session from the History window. Click "image of history toolbar icon" to open the History window.

    You can execute commands and statements stored in a file. Click "image of open toolbar icon" to locate the file using the file browser Open window.

  3. You can specify the character to be used as the termination character for your statements and commands in the Statement termination character field. This termination character will override the character that you may have specified in the Tool Settings notebook.
    You want to specify a different termination character:
    • For scripts containing CREATE PROCEDURE or CREATE TRIGGER statements, it is suggested that a termination character other than a semicolon be used, as the body of these statements might themselves contain one or more semicolons.
    • When stored procedures are using the same character as a delimiter, as this would cause execution problems.
  4. Perform one or more of the following actions:
    • Click "image of execute toolbar icon" to execute the commands or statements.
    • Click "image of access plan toolbar icon" to generate a graphical representation of the access plan for explainable SQL statements (for example, SELECT, INSERT, and UPDATE). An access plan indicates the order of operations for accessing requested data.
    • Click "image of execute and access plan toolbar icon" to execute explainable SQL statements and generate access plans.
    Note: The availability of push buttons changes depending on the target for your commands.
  5. View the execution results. Command results are displayed in the output area of the Commands page, while SQL results are returned on the Query Results page. The access plan appears in graphical form on the Access Plan page.
  6. Optional: The results from the most recently executed SQL statement are displayed on the Query Results page. To change the value in any cell, highlight the value and modify it. If the Automatically commit updates check box is selected, changes made to a cell are committed immediately when focus shifts off its row. If the check box is not selected, then click Commit to commit your changes, or click Rollback to rollback any uncommitted changes.

    You can also add and delete rows in the table.

  7. Optional: You can save your commands and statements in a file. Click "image of save toolbar icon" to specify a file using the file browser Save As window.