Ask a Question
Report a Bug
This page in other versions:
This document in other formats:
The Query Tool is a powerful, feature-rich environment that allows you to
execute arbitrary SQL commands and review the result set. You can access the
Query Tool via the Query Tool menu option on the Tools menu, or through the
context menu of select nodes of the Browser tree control. The Query Tool
allows you to:
You can open multiple copies of the Query tool in individual tabs
simultaneously. To close a copy of the Query tool, click the X in the
upper-right hand corner of the tab bar.
The Query Tool features two panels:
The Query Tool Toolbar
The Query Tool toolbar uses context-sensitive icons that provide shortcuts to
frequently performed tasks. If an icon is highlighted, the option is enabled;
if the icon is grayed-out, the task is disabled. Please note that disabled
icons may support functionality accessed via the data editor.
Hover over an icon to display a tooltip that describes the icon’s functionality:
Click the Save icon to perform a quick-save of a previously saved query, or to access the
Select Save to save the selected content of the SQL Editor panel in a file.
Select Save As to open a new browser dialog and specify a new location to which to save the
selected content of the SQL Editor panel.
Use the Find menu to search, replace, or navigate the code displayed in the SQL Editor:
Select Find to provide a search target, and search the SQL Editor contents.
Select Find next to locate the next occurrence of the search target.
Select Find previous to move to the last occurrence of the search target.
Select Pesistent find to identify all occurrences of the search target within the editor.
Select Replace to locate and replace (with prompting) individual occurrences of the target.
Select Replace all to locate and replace all occurrences of the target within the editor.
Select Jump to navigate to the next occurrence of the search target.
Use options on the Edit menu to access text editing tools; the options operate on the text
displayed in the SQL Editor panel when in Query Tool mode:
Select Indent Selection to indent the currently selected text.
Select Unindent Selection to remove indentation from the currently selected text.
Select Inline Comment Selection to enclose any lines that contain the selection in
SQL style comment notation.
Select Inline Uncomment Selection to remove SQL style comment notation from the
Select Block Comment to enclose all lines that contain the selection in C style
comment notation. This option acts as a toggle.
Click the Filter icon to set filtering and sorting criteria for the data when in View/Edit data
mode. Click the down arrow to access other filtering and sorting options:
Click Sort/Filter to open the sorting and filtering dialogue.
Click Filter by Selection to show only the rows containing the values in the selected cells.
Click Exclude by Selection to show only the rows that do not contain the values in the
Click Remove Sort/Filter to remove any previously selected sort or filtering options.
Click the Execute/Refresh icon to either execute or refresh the query highlighted in the SQL
editor panel. Click the down arrow to access other execution options:
Add a check next to Auto-Rollback to instruct the server to automatically roll back a
transaction if an error occurs during the transaction.
Add a check next to Auto-Commit to instruct the server to automatically commit each
transaction. Any changes made by the transaction will be visible to others, and
durable in the event of a crash.
Click the Explain analyze icon to invoke an EXPLAIN ANALYZE command on the current query.
Navigate through the Explain Options menu to select options for the EXPLAIN command:
Select Verbose to display additional information regarding the query plan.
Select Costs to include information on the estimated startup and total cost of each
plan node, as well as the estimated number of rows and the estimated width of each
Select Buffers to include information on buffer usage.
Select Timing to include information about the startup time and the amount of time
spent in each node of the query.
Use options on the Clear drop-down menu to erase display contents:
Select Clear Query Window to erase the content of the SQL Editor panel.
Select Clear History to erase the content of the History tab.
The SQL Editor Panel
The SQL editor panel is a workspace where you can manually provide a query,
copy a query from another source, or read a query from a file. The SQL editor
features syntax coloring and autocompletion.
To use autocomplete, begin typing your query; when you would like the Query
editor to suggest object names or commands that might be next in your query,
press the Control+Space key combination. For example, type “*SELECT * FROM* ”
(without quotes, but with a trailing space), and then press the Control+Space
key combination to select from a popup menu of autocomplete options.
After entering a query, select the Execute/Refresh icon from the toolbar. The
complete contents of the SQL editor panel will be sent to the database server
for execution. To execute only a section of the code that is displayed in the
SQL editor, highlight the text that you want the server to execute, and click
the Execute/Refresh icon.
The message returned by the server when a command executes is displayed on the
Messages tab. If the command is successful, the Messages tab displays
Options on the Edit menu offer functionality that helps with code formatting
The Data Output Panel
The Data Output panel displays data and statistics generated by the most
recently executed query.
The Data Output tab displays the result set of the query in a table format.
All rowsets from previous queries or commands that are displayed in the Data
Output panel will be discarded when you invoke another query; open another
query tool browser tab to keep your previous results available.
Use the Explain tab to view a graphical representation of a query:
To generate a graphical explain diagram, open the Explain tab, and select
Explain, Explain Analyze, or one or more options from the Explain options
menu on the Execute/Refresh drop-down. Please note that EXPLAIN VERBOSE
cannot be displayed graphically. Hover over an icon on the Explain tab to
review information about that item; a popup window will display information
about the selected object:
Use the download button on top left corner of the Explain canvas to download
the plan as an SVG file.
Note: Download as SVG is not supported on Internet Explorer.
Note that the query plan that accompanies the Explain analyze is available on
the Data Output tab.
Use the Messages tab to view information about the most recently executed
If the server returns an error, the error message will be displayed on the
Messages tab, and the syntax that caused the error will be underlined in the
SQL editor. If a query succeeds, the Messages tab displays how long the
query took to complete and how many rows were retrieved:
Use the Query History tab to review activity for the current session:
The Query History tab displays information about recent commands:
To erase the content of the Query History tab, select Clear history from
the Clear drop-down menu.
Use the Connection status feature to view the current connection and
transaction status by clicking on the status icon in query tool: