Skip to main content
SQL Developer — help/run-sql-script.md
F5 · Ctrl+Enter

How to Run SQL Scripts in SQL Developer

Execute .sql files, run multiple queries at once, and automate your database tasks. This guide covers everything from basic script execution to advanced options.

~/scripts/run.spec execution overview

# Execution modes

run_statement = Ctrl+Enter # single statement at cursor

run_script = F5 # entire worksheet

script_output = F8 # view Script Output panel

# File support

file_type = .sql

max_size = unlimited

encoding = UTF-8 (configurable)

time = 1 minute

difficulty = Beginner

// three ways to open and run shown below

Run Statement vs Run Script

Know the difference — the two modes show results differently and target different parts of your worksheet.

  • Run Statement (Ctrl+Enter) — executes only the single statement where your cursor is. Results appear in a grid. Best for testing individual queries.
  • Run Script (F5) — executes all statements in the worksheet from top to bottom. Output appears in the Script Output panel. Best for running .sql files, migrations, and bulk operations.

How to Run a SQL Script

Three ways to execute your scripts — pick the one that fits your workflow.

METHOD_01

Open and Run

File → Open (or Ctrl+O)
Select your .sql file
Choose a database connection
Press F5 to run

METHOD_02

Drag and Drop

Drag your .sql file directly into SQL Developer's editor area. It opens in a new tab. Select connection and press F5.

METHOD_03

Use @ Command

In any worksheet, type:
@C:\path\to\script.sql
Then press F5. Also works for running scripts from within other scripts.

Understanding Script Output

When you run a script with F5, output appears in the Script Output panel at the bottom of the editor.

  • SELECT results — displayed as text tables
  • DML statements — shows "X rows inserted/updated/deleted"
  • DDL statements — shows "Table created", "Index created", etc.
  • Errors — shows line number and error message

Tip: If you don't see Script Output, go to View → Script Output or press F8.

Advanced Script Options

Three SQL*Plus directives for production-grade scripts.

~/scripts/variables.sqlsubstitution vars

-- Use &name in your script — SQL Developer prompts when you run it

SELECT * FROM users WHERE id = &user_id;

~/scripts/spool.sqlspool output

-- Save script output to a file

SPOOL C:\output.txt

SELECT * FROM users;

SPOOL OFF

~/scripts/strict.sqlexit on error

-- Stop execution if any statement fails — useful for deployments

WHENEVER SQLERROR EXIT;

-- ... rest of your script

Common Script Issues

Four scenarios that trip people up, with fixes.

  • !
    "No connection" error
    You need to select a database connection before running. Look at the dropdown in the toolbar above the editor — select your connection there.
    CONN
  • Script stops at first error
    By default, SQL Developer continues on error. If yours stops, check your script for WHENEVER SQLERROR EXIT. Remove it to continue past errors.
    CFG
  • Nothing happens when I press F5
    Make sure focus is on the SQL editor (click in the editor first). Also check that your script has proper statement terminators (semicolons).
    FOCUS
  • Encoding issues (strange characters)
    Your .sql file might be saved in a different encoding. Try File → Open With Encoding and select UTF-8 or the correct encoding for your file.
    UTF-8

Related Guides

Complementary tasks for working with scripts.

~/downloads ready.sh

Next: Bulk Operations on Result Data

Once a script runs and you have results, the typical next steps are exporting the output (CSV/Excel/JSON) or importing more data to follow up. Both use the same Data Wizard you already know.

// next.specexport-csv.md · import-csv.md
// shortcutskeyboard-shortcuts.md · F5 / Ctrl+Enter