You can develop queries for both relational and XML data
by creating SQL and XQuery statements in the SQL and XQuery editor.
The tool supports the creation of one or more statements of either
type, as well as the nesting of either type of statement. Statements
that you create and save are stored in a file with the extension .sql.
The SQL and XQuery editor provides the following features:
- Connection and commands pane
- The top pane of the editor contains connection information and
command buttons. If no connection is specified for the script, the No
Connection link appears. Click the link to create or specify
a database connection.
The right side of the top border provides
the following command buttons for easy access:
- Debug selected SQL statement
- Run SQL
- Open Visual Explain
- Start Tuning... (shown only in products
that include query-tuning functionality)
- Import
- Export
- Run and collect performance metrics (shown
only in products or features that support performance metrics functionality)
- Job Manager
Note: Debugging SQL statements is supported for DB2® for Linux, UNIX, and Windows Version 10.1 Fix Pack 2 and later
databases.
- Command pane
- The command pane, which is located at the top of the editor, contains
tabs that contain commands that are also available on the pop-up menu
in the editor. You can use either the command pane or the pop-up menu
to perform the actions that are associated with the commands. You
can hide the command pane while you are not using it.
The command
pane contains the Configuration, Validation, Special Registers, and
Performance metrics tabs.
- Multiple statement support
- You can type multiple statements in an .sql file
and then run them.
- Variable statement terminator
- By default, the SQL and XQuery editor uses a semicolon (;)
as the default statement terminator. You can specify a different statement
terminator for the statements that you create in the SQL and XQuery
editor. To set the statement terminator, open a script or use the
Validation tab of the SQL and XQuery editor.
- Syntax highlighting
- To aid you in differentiating the elements in an SQL statement
or an XQuery statement, syntax highlighting renders different kinds
of elements in the text in unique colors.
- Content assist
- Content assist is an editing tool that provides you with helpful
information as you type an SQL or XQuery statement. For example, after
you type the dot that follows a schema qualifier in an SQL statement,
content assist supplies a list of the tables in the schema.
As you
develop your statement, you can press Ctrl + Space at any time to
see context-sensitive coding help in the content assist window.
- Query parsing and validation
- As you type, the parser checks the syntax of both SQL and XQuery
expressions, and provides a visual indication of any errors that it
detects in the query.
Query parsing is optional. If you do not want
to use query parsing, open the Validation tab, select the Validate
statement syntax option, then select No validation from
the list of validation options.