Martyn Cook
Martyn Cook

Reputation: 21

Oracle SQL Developer - Default database connection when running external SQL scripts

What I would like to do, is connect to a database, open a number of external sql files and then execute them against the database I am connected to.

The problem is, when the sql scripts are opened, they do not default to looking at the previously opened connection. Instead, when I run the scripts, they prompt me to select the connection I want. As I have a large number of scripts and a large number of databases, this opens the possibility of human error creeping in and the wrong connection being selected.

My question: Is there a way of opening an external sql script and getting it to default to a specific connection/database?

Many Thanks

Upvotes: 2

Views: 2260

Answers (1)

WW.
WW.

Reputation: 24271

  • Create a file containing a row for each script you want to run, prefixed with @:

    @c:\dev\database\script1.sql

    @c:\dev\database\script2.sql

  • Open this file in SQLDeveloper and click the "Run Script" (F5)

You will only be asked once for the database connection and then it will run each of the files you have specified.

Upvotes: 2

Related Questions