Use the input pane of the database console to compose and execute your SQL statements, and also to perform other, associated tasks. (The input pane is shown as a tab in the editor.)
- Selecting the default schema or database
- Composing SQL statements
- Editing data for INSERT statements in table format
- Navigating to a table or column view in the Database tool window
- Executing an SQL statement
- Executing parameterized statements
- Executing a group of statements
- Executing all statements
- Executing a part of a statement (e.g. a subquery)
- Executing auto-memorized statements
- Outputting the result of a SELECT statement into a file
- Using the error notification bar
- Canceling running statements
- Managing database transactions
- Showing execution plans
- Showing DBMS_OUTPUT for Oracle
Selecting the default schema or database
You can select the default schema or database by using the list in the right-hand part of the toolbar. If you do so, you'll be able to omit the name of that schema or database in your statements.

Composing SQL statements
When composing your SQL statements, use:
-
Predefined patterns
(⌘J or ⌘J⌘J or ⌘J^ J, ⌃J or ⌃J^ J, ⌃J or ⌃J or Code | Insert Live Template).

-
Auto-completion and highlighting of SQL keywords, and table and column names.

-
Data type prompts for columns
(⌘P or ⌘P⌘P or ⌘P⌃⇧Space or ⌃⇧Space^ ⇧ Space, ⌃⇧Space or ⌃⇧Space⇧ ⌥ P, ⌥⇧P or ⌥⇧P or ).

-
Advanced find and replace capabilities
(⌘F or ⌘F⌘F, ⌥F3, ⌘F or ⌥F3^ F, ⌥ F3, ⌃F, ⌥F3, ⌃F or ⌥F3^ ⌥ S, ⌥ F3, ^ S, ⌃⌥S, ⌥F3, ⌃S, ⌃⌥S, ⌥F3 or ⌃S or , and
⌘R or ⌘R⌘R or ⌘R^ H, ⌃H or ⌃H⇧ ⌥ 5, ⌥⇧5 or ⌥⇧5 or ).

-
The console history (
or ⌥⌘E or ⌥⌘E⌥⌘E or ⌥⌘E⌥⌘E or ⌥⌘E^ ⌥ E, ⌃⌥E or ⌃⌥E^ ⌥ E, ⌃⌥E or ⌃⌥E).
See Executing auto-memorized statements.

See also, Navigating to a table or column view in the Database tool window.
Editing data for INSERT statements in table format
-
Select the
INSERTstatement of interest. -
Select Edit as Table from the context menu.
As a result, the table editor opens.

- Use context menu commands and associated shortcuts for working with the data in the table editor.
Navigating to a table or column view in the Database tool window
When composing a statement, it's sometimes useful to take a look at the structure of a table, or to see the info about a column (field) in the context of the table to which it belongs. For such purposes, IntelliJ IDEA provides the ability to switch from the name of a table or column in the input pane to its view in the Database tool window.
The following ways are available for using this feature:
- Place the cursor within the name of the table or column of interest. Then use ⌘B, ⌘Button1 Click, Button2 Click, ⌘B, ⌘Button1 Click or Button2 Click⌘B, ⌘Button1 Click, Button2 Click, ⌘B, ⌘Button1 Click or Button2 ClickF3, ⌃Button1 Click, F3 or ⌃Button1 ClickF12, ⇧ F2, ^ B, ^ Button1 Click, Button2 Click, F12, ⇧F2, ⌃B, ⌃Button1 Click, Button2 Click, F12, ⇧F2, ⌃B, ⌃Button1 Click or Button2 Click^ ⌥ G, Escape, Period, ⌥ Period, ^ Button1 Click, ⌃⌥G, ⎋, ., ⌥., ⌃Button1 Click, ⌃⌥G, ⎋, ., ⌥. or ⌃Button1 Click. (Alternatively, you can use from the main menu or from the context menu.)
-
Press and hold the ^ key, and point to the name of interest.
When the text turns into a hyperlink, click the hyperlink.

Executing an SQL statement
To execute a statement, place the cursor within that statement and do one of the following:
-
Click
on the toolbar. - Press ⌘⏎ or ⌘⏎⌘⏎ or ⌘⏎⌘⏎ or ⌘⏎^ Enter, ⌃⏎ or ⌃⏎^ Enter, ⌃⏎ or ⌃⏎.
- Select Execute from the context menu.
If more than one statement can be run for the current cursor position, you can select which of the statement you want to run.

See also, Execute in Console.
Executing parameterized statements
Your statements can contain parameters, however, by the time you execute such statements the values of the parameters must be specified. There are the following ways of specifying the parameter values:
-
Click
on the toolbar or press
⌘⏎ or ⌘⏎⌘⏎ or ⌘⏎⌘⏎ or ⌘⏎^ Enter, ⌃⏎ or ⌃⏎^ Enter, ⌃⏎ or ⌃⏎
to execute the statement.
In the dialog that opens, specify the parameter values and click OK.

( To start editing a value, switch to the corresponding table cell and start typing. To indicate that you have finished editing a value, press ⏎ or ⏎⏎ or ⏎⏎ or ⏎Enter, ⏎ or ⏎Enter, ^ M, ⏎, ⌃M, ⏎ or ⌃M or switch to a different cell. To quit the editing mode and restore an initial value, press ⎋ or ⎋⎋ or ⎋⎋ or ⎋Escape, ⎋ or ⎋Escape, Escape, ^ G, ⎋, ⎋, ⌃G, ⎋, ⎋ or ⌃G. )
-
Alternatively, you can open the Parameters pane
in the Database Console tool window
(
on the toolbar) and specify the corresponding values there.
(The values are edited in the same way as in the corresponding dialog.)
Then execute the statement
(
on the toolbar or
⌘⏎ or ⌘⏎⌘⏎ or ⌘⏎⌘⏎ or ⌘⏎^ Enter, ⌃⏎ or ⌃⏎^ Enter, ⌃⏎ or ⌃⏎).

For more information, see Parameters pane.
See also, User Parameters and Always review parameters before execution.
Executing a group of statements
To execute a group of statements that follow one another in the console, select (highlight) the statements to be executed (to select all the statements, use ⌘A or ⌘A⌘A or ⌘A⌘A or ⌘A^ A, ⌃A or ⌃A^ X, H, ⌃X, H or ⌃X, H) and do one of the following:
-
Click
on the toolbar. - Press ⌘⏎ or ⌘⏎⌘⏎ or ⌘⏎⌘⏎ or ⌘⏎^ Enter, ⌃⏎ or ⌃⏎^ Enter, ⌃⏎ or ⌃⏎.
- Select Execute from the context menu.
See also, Using the error notification bar and Executing all statements.
Executing all statements
To execute all the statements contained in a console, do one of the following:
- Right-click the editing area and select Run console.sql.
- Press ⌃⇧R or ⌃⇧R⌃⇧F10 or ⌃⇧F10⌃⇧R or ⌃⇧R^ F9, ⌃F9 or ⌃F9^ ⇧ F10, ⌃⇧F10 or ⌃⇧F10.
See also, Executing a group of statements.
Executing a part of a statement (e.g. a subquery)
To execute a part of a statement (e. g. a subquery), select (highlight) the fragment that you want to execute and do one of the following:
-
Click
on the toolbar. - Press ⌘⏎ or ⌘⏎⌘⏎ or ⌘⏎⌘⏎ or ⌘⏎^ Enter, ⌃⏎ or ⌃⏎^ Enter, ⌃⏎ or ⌃⏎.
- Select Execute from the context menu.
See also, Execute in Console.
Executing auto-memorized statements
As you run SQL statements in the consoles, IntelliJ IDEA memorizes them. So, at a later time, you can view the statements you have already run and, if necessary, run them again.
To open the dialog where the auto-memorized statements are shown (the History dialog), do one of the following:
-
Click
on the toolbar. - Press ⌥⌘E or ⌥⌘E⌥⌘E or ⌥⌘E⌥⌘E or ⌥⌘E^ ⌥ E, ⌃⌥E or ⌃⌥E^ ⌥ E, ⌃⌥E or ⌃⌥E.
There are two panes in the History dialog. The left-hand pane shows the list of the statements that you have run. For "long" statements, only their beginnings are shown. When you select a statement in this pane, the overall statement is shown in the pane to the right.
You can filter the information: just start typing. As a result, only the statements that contain the typed text will be shown.
You can copy the statements from the History dialog into the input pane of the console. To copy a statement, do one of the following:
- Double-click the statement to be copied.
- Select the statement of interest and press ⏎ or ⏎⏎ or ⏎⏎ or ⏎Enter, ⏎ or ⏎Enter, ^ M, ⏎, ⌃M, ⏎ or ⌃M.
- Select the statement and click OK.
(Once the statement is in the input pane, you can run it straight away.)
You can delete unnecessary memorized statements. To delete a statement, select the statement in the History dialog and press ⌦, ⌫, ⌘⌫, ⌦, ⌫ or ⌘⌫⌦, ⌫, ⌘⌫, ⌦, ⌫ or ⌘⌫⌦, ⌫, ⌘⌫, ⌦, ⌫ or ⌘⌫Delete, ⌦ or ⌦Delete, ^ D, ⌦, ⌃D, ⌦ or ⌃D.
Outputting the result of a SELECT statement into a file
Instead of the Result pane of the Database Console tool window,
you can output the result of a SELECT statement into a file.
- Right-click the
SELECTstatement of interest. - Point to Execute to File and select the output format.
- Specify the output file location and name.
Using the error notification bar
If when running a statement an error occurs, an error notification bar appears in the lower part of the input pane.
This bar may be particularly useful when executing a sequence of statements (see Executing a group of statements) because in such a case it lets you select how to react.

The options are:
- Retry. Execute the sequence of statements starting from the one that caused the error.
- Ignore. Skip the erroneous statement and execute the sequence starting from the next statement. If another error occurs, the error notification bar will appear again.
- Ignore All. Skip the erroneous statement and execute the sequence starting from the next statement. If other errors occur, all the erroneous statements will be skipped and the error notification bar won't appear for these statements.
- Stop. Stop the execution of the sequence.
Showing the error notification bar in the input pane is enabled or disabled in the Preferences dialog (the Show error notifications in editor check box on the Database page).
Canceling running statements
To terminate execution of the current statement or statements, do one of the following:
-
Click
on the toolbar of the input pane, or
on the toolbar of the Dababase Console tool window. - Press ⌘F2 or ⌘F2⌘F2 or ⌘F2⌘F2 or ⌘F2⇧ F5, ⇧F5 or ⇧F5^ F2, ⌃F2 or ⌃F2 .
Managing database transactions
The Auto-commit check box, and
the Commit
and
Rollback
icons on the toolbar
let you manage database transactions.
The Auto-commit check box is used to turn the autocommit mode for the database connection on or off.
In the autocommit mode, each SQL statement is executed in its own transaction that is implicitly committed. Consequently, the SQL statements executed in this mode cannot be rolled back.
If the autocommit mode is off, transactions are committed or rolled back explicitly by means of
the Commit (
) or
Rollback (
) command.
Each commit or rollback starts a new transaction which provides grouping
for a series of subsequent SQL statements.
In this case, the data manipulations in the transaction scope are committed or rolled back all at once when the transaction is committed or rolled back.
Showing execution plans
The following context menu commands let you show
an execution plan
(a.k.a. explain plan) for a statement:
- Explain Plan. The result is shown in a mixed tree/table format on a dedicated Plan tab.
-
Explain Plan (Raw).
The result is shown in table format.
(Technically,
EXPLAIN <CURRENT_STATEMENT>or similar statement is executed.)
Showing DBMS_OUTPUT for Oracle
For Oracle, you can enable or disable showing the contents of the DBMS_OUTPUT buffer in the output pane.
To do that, use
on the toolbar of
the Database Console tool window
(⌘F8 or ⌘F8⌘F8 or ⌘F8⇧⌘B or ⇧⌘BF9, F9 or F9^ F8, ⌃F8 or ⌃F8).
