Query consoles
warning
The following is only valid when the Database Tools and SQL plugin is installed and enabled.
Query or database consoles are SQL files in which you can compose and execute SQL statements. Unlike scratch files, consoles are attached to a data source. You can use a query console in the same way as you use a terminal. Just type and run your code.
When you create a data source, a query console is created automatically. If necessary, you can create additional consoles. Each console creates a new connection. If you do not want to create new connections, enable single session mode.
All the created query consoles are located in the internal Database Consoles directory. To open this folder, open the Project tool window () and navigate to Scratches and Consoles | Database Consoles. On your machine, the query console files are stored in the consoles subdirectory of the IDE configuration directory.
For information about working with query results in query consoles, refer to Query results.
To create a console, use one of the following actions in the Database tool window ( View | Tool Windows | Database).
Click a data source and select File | New | Query Console.
Right-click a data source and select New | Query Console.
Click a data source, press , and select Query Console.
Click a data source, press , and select New Query Console.
Click a data source and press .
note
New console means a new connection to a data source. You can work with just one connection for the data source and have all consoles use that same one connection. Read more about the single session mode in Single session mode.
When a console is open, you can write SQL here, run it and get the result.
In the Project tool window (View | Tool Windows | Project), navigate to Scratches and Consoles | Database Consoles | <data_source_name>, double-click a console file.
In the Database tool window, click the Jump to Query Console… icon () and select a console that you want to open or create a new one.
Click a data source, press , and select the console that you need.
To rename a query console file, do one of the following:
Right-click a console tab, and select Rename File.
Open the Project tool window (View | Tool Windows | Project) and navigate to Scratches and Consoles | Database Consoles. Expand a data source group that includes your console, right-click the console file, and select Refactor | Rename ().
In the Project tool window (View | Tool Windows | Project), navigate to Scratches and Consoles | Database Consoles.
Right-click a data source group where you want to create a new directory, select New | Directory.
Specify a name of the directory.
Select and drag console files to the directory.
In the Move dialog, click OK.
In the Project tool window (View | Tool Windows | Project), navigate to Scratches and Consoles | Database Consoles.
Expand a data source group that includes your console.
Right-click a console file and select Delete.
In the Project tool window (View | Tool Windows | Project), navigate to Scratches and Consoles | Database Consoles.
Expand a data source group that includes your console.
Right-click a console file and select Refactor | Copy File….
In the To directory field, specify a new location for the file.
To open a console file in your file browser, do one of the following:
Right-click a console tab and navigate to Open in | <file_browser>.
Open the Project tool window (View | Tool Windows | Project) and navigate to Scratches and Consoles | Database Consoles. Expand a data source group that includes your console, right-click the console file, and select Open in | <file_browser>.
Open a console and click the Data Source Properties icon ().
Right-click the editing area and select Change Dialect (<current_dialect>) to. In the Change SQL Dialect window, select a dialect.
note
For query consoles, SQL dialect is defined by a data source that is attached to the console. It can only be changed for the Oracle consoles.
Right-click the editing area of the input pane, select Change Dialect, and select Generic SQL. The Generic SQL dialect supports completion and highlighting for SQL keywords, table and column names. Syntax error highlighting is disabled, that is all statements in a query console are shown as syntactically correct).
In a console, right-click any area and select Local History | Show History.
Right-click any area or a selection of code in the editor and select Reformat. Alternatively, press .
To see the details of a file, hover the cursor over the console tab.
Press , select Files View and press .