Skip to content

SQL Script Task

dbeaver-devops edited this page Mar 24, 2026 · 2 revisions

Note: This feature is available in Community, Enterprise, and Ultimate editions only.

Table of contents

DBeaver allows you to create SQL Script tasks that execute one or more saved SQL scripts. For example, you can group maintenance or cleanup scripts into a single task and run them together at a scheduled time or on demand.

For more details on creating and running tasks, see Task management.

Creating an SQL Script task

  1. To start creating an SQL Script task, open the Create a task dialog. You can do this by:

    • Right-clicking in the database navigator and selecting Tools -> Create new task...
    • Clicking on Database -> Tasks -> Create new task...
    • Navigating to Database -> Tasks -> Database tasks, right-clicking, and choosing Create new task...

    In the Create a task wizard, select SQL Script. Enter a name, and optionally add a description and a task folder. Click Next to continue.

  2. In the task configuration dialog, configure scripts and execution options:

    1. Add scripts to the task using these controls:

      Button Button image Description
      Add script Add a saved scripts from the local workspace.
      Browse remote file system Add a script from Cloud Storage

      When you add a script, DBeaver automatically assigns the connection associated with that script. The connection appears in the Connections list.

      Tip: You can add additional connections if the same script must run against multiple environments.

      Note: Scripts run in the order shown in the list.

    2. (Optional) Use settings to control how the added scripts are executed within the task:

      Setting Description
      Ignore errors Continue execution if a script fails.
      Dump query results to log file Write query results to the log.
      Auto-commit Commit each statement automatically.

      Warning: When Auto-commit is enabled, changes are committed immediately and can’t be rolled back.

    3. (Optional) Configure variables to pass values into scripts at runtime:

      1. Click Configure
      2. Select the SQL Script task
      3. Click Add button () and enter the variable name and default value

      Tip: Enable Show variables before run to enter variable values each time the task runs.

      Example:

      You can use variables to make a single SQL Script task reusable across environments.

      DELETE FROM audit_log
      WHERE log_date < ${cleanup_before};

      Example task variable:

      Variable Value
      cleanup_before 2023-01-01
  3. After setting up the scripts, execution options, and variables, click Proceed to save and start the SQL Script task.

Tip: You can set a timeout for each task to avoid blocking others.

Editing an SQL Script task

To edit an SQL Script task, go to Database -> Tasks -> Database tasks. Here, you can edit scripts, change execution settings, configure variables, or reorder scripts in the task.

DBeaver Documentation

Clone this wiki locally