RubyMine 7.0.1 Web Help

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.)

Composing SQL statements

When composing your SQL statements, use:

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

    sqlConsoleAutocompletion

  • Context-sensitive suggestions (a.k.a. basic code completion) activated by means of Ctrl+SpaceCtrl+SpaceCtrl+SpaceCtrl+SpaceAlt+SlashCtrl+SpaceCtrl+Space or Ctrl+Back SlashCtrl+SpaceCtrl+SpaceControl SpaceControl SpaceControl SpaceControl Space, Alt Escape or Shift Space or Code | Completion | Basic.

    sqlConsoleCodeCompletion

  • Data type prompts for columns (fields) invoked by Ctrl+PCtrl+PCtrl+PCtrl+PShift+Alt+PCtrl+Shift+SpaceCtrl+PCtrl+P⌘+P⌘ P⌘ PControl Shift Space⌘ P or View | Parameter Info.

    sqlConsoleParameterInfoTooltip

  • Advanced find and replace capabilities (Ctrl+F or Alt+F3Ctrl+F or Shift+Alt+3Ctrl+F or Shift+Alt+3Ctrl+F or Alt+F3Ctrl+Alt+S, Alt+F3 or Ctrl+SCtrl+F or Alt+F3Ctrl+F or Alt+F3Ctrl+F or Alt+F3⌘+F or Alt+F3⌘ F⌘ F or Alt F3⌘ F⌘ F or Alt F3 or Edit | Find | Find, and Ctrl+RCtrl+RCtrl+RCtrl+RShift+Alt+5Ctrl+HCtrl+HCtrl+FAlt+⌘+F⌘ R⌘ R⌘ R⌘ R or Edit | Find | Replace).

    sqlConsoleFindAndReplace

See also, Navigating to a table or column view in the Database tool window.

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, RubyMine provides the ability to switch from a table or column referenced 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 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 ClickF12, Shift+F2, Ctrl+B, Ctrl+Button1 Click or Button2 ClickCtrl+B, Ctrl+Button1 Click or Button2 ClickF3 or Ctrl+Button1 Click⌘+B, ⌘+Button1 Click or Button2 Click⌘ B, ⌘ Button1 Click or Button2 Click⌘ B, ⌘ Button1 Click or Button2 ClickF3 or Control Button1 Click⌘ B, ⌘ Button1 Click or Button2 Click. (Alternatively, you can use Navigate | Declaration from the main menu or Go To | Declaration from the context menu.)
  • Press and hold the Ctrl key, and point to the name of interest. When the text turns into a hyperlink, click the hyperlink.

    sqlConsole1

Executing an SQL statement

To execute a statement, place the cursor within that statement or within the line that contains the statement. Then do one of the following:

  • Click runBuild on the toolbar.
  • Press Ctrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+Enter⌘+Enter⌘ Enter⌘ Enter⌘ Enter⌘ Enter.

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 runBuild on the toolbar or press Ctrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+Enter⌘+Enter⌘ Enter⌘ Enter⌘ Enter⌘ Enter to execute the statement. In the dialog that opens, specify the parameter values and click OK.

    sqlConsoleParams

    ( To start editing a value, double-click the corresponding table cell, or click the cell and press F2 or Alt+EnterF2 or Alt+EnterF2 or Alt+EnterF2 or Alt+EnterF2 or Alt+EnterF2 or Alt+EnterF2 or Alt+EnterF2 or Alt+EnterF2 or Alt+EnterF2 or Alt EnterF2 or Alt EnterF2 or Alt EnterF2 or Alt Enter. To indicate that you have finished editing a value, press EnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnter or click a different cell. To quit the editing mode and restore an initial value, press EscapeEscapeEscapeEscapeEscape, Escape or Ctrl+GEscapeEscapeEscapeEscapeEscapeEscapeEscapeEscape. )

  • Alternatively, you can open the Parameters pane in the Database Console tool window (property_yellow 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 (runBuild on the toolbar or Ctrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+Enter⌘+Enter⌘ Enter⌘ Enter⌘ Enter⌘ Enter).

    sqlConsoleParamsPane

    For more information, see Parameters pane.

See also, Custom SQL parameters.

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 Ctrl+ACtrl+ACtrl+ACtrl+ACtrl+X, HCtrl+ACtrl+ACtrl+A⌘+A⌘ A⌘ A⌘ A⌘ A) and do one of the following:

  • Click runBuild on the toolbar.
  • Press Ctrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+EnterCtrl+Enter⌘+Enter⌘ Enter⌘ Enter⌘ Enter⌘ Enter.

See also, Using the error notification bar.

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.

DBConsoleErrorNotificationBar

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 Settings dialog (the Show error notifications in editor check box on the Database page).

Executing a part of a statement (e.g. a subquery)

To execute a part of a statement (e. g. a subquery):

  1. Select (highlight) the fragment that you want to execute.
  2. Right-click the fragment and select Execute Selection from the context menu.

See also, Execute Selection.

Executing auto-memorized statements

As you run SQL statements in the console, RubyMine 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 consoleHistory on the toolbar.
  • Press Ctrl+Alt+ECtrl+Alt+ECtrl+Alt+ECtrl+Alt+ECtrl+Alt+ECtrl+Alt+ECtrl+Alt+ECtrl+Alt+EAlt+⌘+EAlt ⌘ EAlt ⌘ EAlt ⌘ EAlt ⌘ 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 specified string 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 EnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnter.
  • 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 DeleteDeleteDeleteDeleteDelete or Ctrl+DDeleteDeleteDeleteDelete or ⌘+BackspaceDelete, Backspace or ⌘ BackspaceDelete, Backspace or ⌘ BackspaceDelete, Backspace or ⌘ BackspaceDelete or ⌘ Backspace.

Note:

  • There is a separate history of executed statements for each of your DB data sources.
  • The number of executed SQL statements to be memorized can be changed in the Settings dialog (the Console commands history size field on the Editor | General page).
  • 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.

Managing database transactions

The Auto-commit check box, and the Commit DBCommit and Rollback DBRollback 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 (DBCommit) or Rollback (DBRollback) 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.

Canceling running statements

To terminate execution of the current statement or statements, do one of the following:

  • Click stop on the toolbar of the input pane, or on the toolbar of the Dababase Console tool window.
  • Press Ctrl+Shift+Alt+DeleteCtrl+Shift+Alt+DeleteCtrl+Shift+Alt+DeleteCtrl+Shift+Alt+DeleteCtrl+Shift+Alt+DeleteCtrl+Shift+Alt+DeleteCtrl+Shift+Alt+DeleteCtrl+Shift+Alt+DeleteShift+Alt+⌘+DeleteShift Alt ⌘ DeleteShift Alt ⌘ DeleteShift Alt ⌘ DeleteShift Alt ⌘ Delete .

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 DBConsoleEnableDBMSOutputIcon on the toolbar of the Database Console tool window (Ctrl+F8Ctrl+F8Ctrl+8Ctrl+F8Ctrl+F8F9Ctrl+F8Ctrl+Shift+B or Ctrl+F8Ctrl+B⌘ F8⌘ F8Shift ⌘ BShift F7).

DBConsoleDBMSOutput

See Also

Procedures:

Language and Framework-Specific Guidelines:

Reference:

Web Resources: