Running SQL Script Files
This feature is supported in the Ultimate edition only.
You can run an SQL file as a whole. You can also execute individual statements contained in an SQL file.
Running an SQL file
When running an SQL script file as a whole:
- You don't need to open the file in the editor. You can select the necessary file in the Project tool window.
- You can run the file for more than one data source at once.
On the other hand:
To run an SQL file:
- Select the necessary SQL file in the Project tool window, or open the file in the editor.
- Do one of the following:
- In the Choose Data Source pop-up, click the data source to which the script should be applied.
If you want to run the script for more than one data source, select the data sources of interest in the pop-up and press Enter.
Executing individual statements
When running individual statements contained in an SQL file:
- The statements can contain parameters. Prior to running such statements IntelliJ IDEA will ask you to specify the parameter values.
On the other hand:
To run a statement or statements:
- Open the SQL file of interest in the editor.
- Place the cursor within the statement you want to execute.
If you want to run more than one statement, select (highlight) the necessary statements.
- Do one of the following:
- Select the database console to be used.
The statement or statements are executed using the selected console. The corresponding console is associated with the file. The name of the associated console is shown in the right-hand part of the toolbar.
The menu for the console name, lets you associate a different console with the file, or remove the association between the file and the console (<Detach Console>).