IntelliJ IDEA 12.1.0 Web Help

Some features described here are available in Ultimate edition only.

Prior to running SQL commands, you may want to check and, if necessary, change the SQL dialect to be used.

When typing the SQL commands in the Input pane of the Database Console tool window (this pane opens as a new editor tab), use various kinds of coding assistance, such as code-specific completion, syntax and error highlighting, completion of the data source, table and column names. You may also be interested in using the following features:

Run the command when ready.

As you run the SQL statements, IntelliJ IDEA memorizes them. So, at a later time, you can view the statements you have already run and, if necessary, run them again.

There are two ways of working with the history of executed SQL statements. You can:

Note

Note that:

  • There is a separate history of executed statements for each of your data sources.
  • The number of executed SQL statements to be memorized may be changed by editing the value of Console commands history size in the Editor page of the IDE Settings.
  • The history files that haven't been used for two weeks are automatically deleted. That is, if you haven't run SQL statements for a certain data source within this time, the corresponding history is discarded.
Changing the SQL dialect
  1. Open the Database Console for the data source of interest.
  2. Click the Properties button properties.gif on the toolbar.
  3. In the Database Console Properties dialog that opens, select the General tab.
  4. Select the desired dialect from the SQL Dialect list and click OK.
Viewing parameter information

When typing an SQL statement, you can view parameter information on-the-fly or by pressing Ctrl+PCtrl+PCtrl+PCtrl+PShift+Alt+PCtrl+PCtrl+Shift+SpaceCtrl+PCtrl+PMeta PMeta PControl Shift Space. IntelliJ IDEA informs you about the type of required parameters in a tooltip.

sqlConsoleParameterInfoTooltip.png

Using parameters in commands

You can use parameters in SQL statements and specify which values should be used in place of these parameters when running the statements:

  1. When typing a command, enclose the parameters in #, $, or ? characters.
  2. In the Parameters pane, specify the values to substitute for the corresponding parameters at command execution.

    sqlConsoleParams.png

Navigating from a reference in the query to the corresponding table

Do one of the following:

  • Place the caret at the desired name and press Ctrl+B, Ctrl+Button1 Click or Button2 ClickCtrl+B, Ctrl+Button1 Click or Button2 ClickCtrl+B, Ctrl+Button1 Click or Button2 ClickCtrl+B, Ctrl+Button1 Click or Button2 ClickCtrl+Alt+G, Escape, Period, Alt+Period or Ctrl+Button1 ClickCtrl+B, Ctrl+Button1 Click or Button2 ClickF12, Shift+F2, Ctrl+B, Ctrl+Button1 Click or Button2 ClickCtrl+B, Ctrl+Button1 Click or Button2 ClickF3 or Ctrl+Button1 ClickMeta B, Meta Button1 Click or Button2 ClickMeta B, Meta Button1 Click or Button2 ClickF3 or Control Button1 Click. The corresponding table and column are highlighted in the data source for which the console was launched.
  • With the Ctrl key pressed, hover the mouse pointer over the reference to a table or column. So doing, the corresponding table or column declaration is displayed in a tooltip, and the reference turns to a hyperlink. Click the link to jump to the declaration in the data source.

    sqlConsole1.png

Running SQL commands

You can run the SQL statements one at a time, or execute a number of statements that follow one another in the console at once:

  • To execute a command at the caret, press Ctrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterMeta EnterMeta EnterMeta Enter or click runBuild.gif on the toolbar.
  • To run several consecutive commands, select them in the console. Then, press Ctrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterMeta EnterMeta EnterMeta Enter or click runBuild.gif on the toolbar.

    Tip

    You can prepare a script in an SQL file, copy and then paste its contents into the Input pane.

Browsing the executed SQL statements in the input pane

When working with the Input pane of the Database Console tool window, you can browse the executed SQL statements one by one by moving to the previous or next statement:

  • To navigate to the previous statement, press Ctrl+UpCtrl+UpCtrl+UpCtrl+UpCtrl+UpCtrl+UpCtrl+UpCtrl+UpCtrl+UpMeta UpMeta UpMeta Up.
  • To navigate to the next statement, press Ctrl+DownCtrl+DownCtrl+DownCtrl+DownCtrl+DownCtrl+DownCtrl+DownCtrl+DownCtrl+DownMeta DownMeta DownMeta Down.
10.5+
Working with the executed SQL statements in the history dialog

When working with the Input pane of the Database Console tool window, you can open the history dialog to see the executed SQL statements all at once.

To open this dialog:

  • Press Ctrl+ECtrl+ECtrl+ECtrl+ECtrl+ECtrl+ECtrl+EShift+F4Ctrl+EMeta EMeta EMeta E.

In this dialog, you can:

  • Navigate through the list of the executed statements using the UpUpUpUpUp or Ctrl+PUpUpUpUpUpUpUp or Control P and DownDownDownDownDown or Ctrl+NDownDownDownDownDownDownDown or Control N arrow keys.
  • Remove the statements from the history. To delete a statement, select (navigate to) the statement to be deleted and press DeleteDeleteDeleteDeleteDelete or Ctrl+DDeleteDeleteDeleteDeleteDeleteDeleteDelete or Backspace.
  • Copy the statements to the Input pane. To copy a statement, do one of the following:
    • Double-click the statement to be copied.
    • Select (navigate to) the statement of interest and press EnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnter.
    • Select the statement and click OK.

    As a result, the history dialog closes and the selected statement is copied to the Input pane.

See Also

Procedures:

Language and Framework-Specific Guidelines:

Reference:

Web Resources: