# Execute SQL Script File

SQLife's SQL Executor runs a script file against the active database connection. Use it for migrations, seed data, and scripts that are inconvenient to paste into the editor.

## Open the SQL Executor

1. Connect to a database.
2. Open **Database -> SQL Executor**.
3. Select a script file.

The executor displays a read-only SQL preview and a read-only execution log.

## Options

The current executor provides these controls:

- **Remember history**: retain the script in executor history.
- **Ignore error**: continue after errors instead of stopping at the first failure.
- **Support LOB**: enable handling for large text and binary values.
- **Unescape line break**: convert escaped line breaks in input.
- **Disable foreign key**: temporarily disable foreign-key handling where supported by the database integration.
- **Default schema**: execute using a selected schema.

The current SQL Executor does not expose a thread-count or commit-batch control. Do not assume that statements run in parallel or that SQLife inserts automatic commits. Put transaction control in the script when the database supports it and verify the result before committing production changes.

## Execute a Script

1. Select the script file.
2. Review the SQL preview.
3. Select the schema and options.
4. Click **Execute**.
5. Read the execution log for database errors.

Use a script separator accepted by the target database and its driver. PL/SQL scripts may require the separators expected by the Oracle integration.

## Safe Operating Procedure

- Test the script against a development or disposable database first.
- Back up important data before DDL or bulk DML.
- Keep `Ignore error` disabled when every statement must succeed.
- If errors are ignored, inspect the log and validate the affected rows afterward.
- Use explicit `COMMIT` and `ROLLBACK` statements where appropriate.
- Do not select **Disable foreign key** unless you understand the integrity implications and have a re-enable plan.

## Troubleshooting

- If execution cannot start, verify the connection, file path, encoding, and database permissions.
- If many statements fail, check the script dialect and statement separators.
- If a script is slow, inspect the database plan and split independent work into smaller scripts. The SQL Executor does not provide a parallel execution setting.
- If LOB values fail, enable **Support LOB** and verify the source literal format.
