GoLand 2020.1 Help

Run database code

You can run your code by using shortcuts, toolbar buttons and icons, a context menu, and run/debug configurations. You can run a query from query consoles, scratch files, and user files.

Run statements from an open file

In GoLand, you can open and run a file. Limitation for the file size is 20 MB. When you open a file that is larger than 20 MB, you see only first 2.5 MB of the file.

  1. Open the Project tool window (View | Tool Windows | Project) and double-click an SQL file. For more information about attaching directories and files in GoLand, see User files.

  2. Click the statement that you want to execute. To run a selection of several statements, select (highlight) the statements.

  3. Press Ctrl+Enter or select Execute from the context menu.

  4. (Optional) If the SQL file is not connected to a data source, select or create a connection session in the <session> list. For more information about sessions, see Run database code.

  5. In the Statements window, press Enter to run the selected statement. You can switch between other entries to run another set of statements. Statements that you are going to execute are highlighted in the editor.

Run an SQL file from a hard drive

  1. In the Database tool window (View | Tool Windows | Database), right-click a data source.

  2. Select Run SQL Script.

  3. In the Select Path window, navigate to the SQL file that you want to apply.

    Run an SQL file

Run an SQL file for several data sources

To run an SQL file for several data sources, attach a directory with the necessary files in the Project tool window (see User files).

  1. In the Project tool window (View | Tool Windows | Project), select files that you want to run.

  2. Right-click the selection and navigate to Run <configuration_name> (or press Ctrl+Shift+F10). This action creates a temporary run configuration.

  3. In the Edit configuration window, click the Add button (the Add button) and select data sources or schemes against which you want to run selected files.

  4. Click Run.

    Run files for several data sources

Execute statements in a query console

When you create a data source, a query console is created automatically. For more information about database consoles, see Query consoles.

You can relate to a query console as to a terminal where you type and run your code.

  1. In the Database tool window (View | Tool Windows | Database), click the data source.

  2. Open F4 or create (Ctrl+Shift+F10 | New Console) a query console. For more information about working with consoles, see Working with consoles.

  3. Type or paste the statement that you want to execute.

  4. Press Ctrl+Enter. Alternatively, click the Execute icon The Execute icon on the toolbar.

    If you have several statements, select whether you want to execute all statements or a single statement. The suggestion list always contains an item for running all the statements.

Run files by using run configurations

Depending on your purposes, you can edit existing or create new configurations. For more information about editing you configurations, see Create and edit run/debug configurations.

  1. Open the Run/Debug Configuration dialog in one of the following ways:

    • Select Run | Edit Configurations from the main menu.

    • With the Navigation bar visible (View | Appearance | Navigation Bar), choose Edit Configurations from the run/debug configuration selector.

    • Press Shift+Alt+F10, then press 0 or select the configuration from the popup and press F4.

  2. In the Run/Debug Configuration dialog, click the Add New Configuration icon (the Add New Configuration icon) and select SQL Script.

    The fields that appear in the right-hand pane display the default settings for the selected configuration type.

    • Target data source / schema: databases or schemas against which you want to run your SQL code. This setting is dialect-dependent.

    • Script text: code that you want to run.

    • Script Files: SQL files that you want to run. To add files, click the Add button (the Add button) and navigate to files that you want to run.

    • Data source (utPLSQL and tSQLt): a name of a data source. utPLSQL supports Oracle. tSQLt supports Microsoft SQL Server.

    • Database (tSQLt): a name of the Microsoft SQL Server database.

    • Paths (utPLSQL and tSQLt): a qualified path to the testing package.

    • Tags (utPLSQL): tags of tests that you want to run. Use semicolon (;) as separator.

  3. Apply the changes and close the dialog.

  4. Click the Run <configuration_name> button The Run button.

Productivity tips

Execute a file from the search dialog

  1. Press Shift twice.

  2. In the Search Everywhere dialog, type the filename.

  3. Select a file by using Up and Down arrows.

  4. Press Ctrl+Shift+F10.

  5. In the Edit configuration window, click the Add button (the Add button) and select data sources or schemes against which you want to run selected files.

Disable in-editor results

  • To disable the In-editor results feature for all files across the IDE, open settings by pressing Ctrl+Alt+S and navigate to Database | General. Clear the Show output results in the editor checkbox.

  • To disable the In-editor results feature for the current file, click the In-editor results icon.

    Disable in-editor results for the current file
Last modified: 17 March 2020