DB2 Command and SQL Consoles

Opening and working with DB2 Consoles

To open the DB2 Command Console or the DB2 SQL Console:

This will show the standard Eclipse Console view if it isn't already shown, and open a console to the selected DB2 subsystem.

Note that the console view is shared among all consoles in Eclipse. You can manually choose which console is currently shown in the Console view by clicking the Display Selected Console button in the Console view's toolbar and selecting the desired console from the popup menu which appears.

To lock the current console in this console view and prevent other consoles from taking it over, you can click the Pin Console button in the Console view's toolbar. After doing so, if a console is created, it will cause a new instance of the Console view to be created, leaving the existing Console view unchanged.

Once a console is open, it can be displayed in as many Console views as required. To create a new console view, click the Open Console button, then select New Console View from the popup menu that appears.

You can clear the output of the console or close the Console by clicking the Clear Console and Close Console buttons on the Console view's toolbar respectively.

Previous commands you enter in a DB2 console will be retained in the command history for the console while it remains open. You can access the command history in four ways:

Back to top

DB2 Command Console

The DB2 Command Console allows you to enter DB2 administrative commands. For example, you can enter

DIS DATABASE (*)
to list existing databases (note that the recognition character, typically a hyphen, should not be entered).

As you enter text, the console will perform limited syntax highlighting on the commands, keywords, and keyword parameters. Note that only recognised commands will be highlighted.

If you press Control+Space, the console will provide a list of content proposals. This can be used to see the list of available commands, and keywords. Command proposals will include a link to the documentation for the selected command.

Limitation: Syntax highlighting and content proposals always use DB2 v10 syntax. While the DB2 Command Console can be used with other supported versions of DB2, the syntax highlighting and content proposals provided by the DB2 Command Console may be incorrect.

DB2 SQL Console

The DB2 SQL Console allows you to evaluate DB2 SQL statements. For example, you can enter

SELECT NAME FROM SYSIBM.SYSTABLES;
to list the names of all the tables in the DB2 subsystem. Your SQL statement must finish with a semicolon immediately followed by a newline character (i.e. type a semicolon then press the Enter key). If this is not done, the statement will not be executed (this is to allow SQL statements over multiple lines).

The output of select statements will be formatted as a textual table.

As you enter text, the console will syntax highlight recognized primary SQL statement commands. The remainder of the SQL statements will not be syntax highlighted.

If you press Control+Space, the console will provide a list of content proposals. This can be used to see the list of available primary SQL statement commands. Proposals will include a link to the documentation for the selected command.

Limitation: Syntax highlighting and content proposals always use DB2 v10 syntax. While the DB2 SQL Console can be used with other supported versions of DB2, the syntax highlighting and content proposals provided by the DB2 SQL Console may be incorrect.

Limitation: All limitations which apply to File Manager DB2's SQL Execute functionality also apply to the DB2 SQL Console. For example, if File Manager DB2's SQL Execution functionality cannot SELECT columns of BLOB type, then this will fail in the DB2 SQL Console as well.

Back to top

Using a custom DB2 Infocenter for DB2 Documentation

The information popup for a command in a DB2 console will contain a link to the documentation (the info center page) for that command. The info center used by default is http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp, but this can be customized in the File Manager preference pane.

Back to top