Skip to content

SnipIT No 4: Run an Oracle SQL script from DOS prompt

15/05/2015

SnipIT is a series of short blogs containing useful information in an easily digestible format.

To run an Oracle SQL script file from a DOS prompt (Command Line) you execute sqlplus passing credentials and the database name along with the script to run.

@sqlplus.exe <username>/<password>@<database name> @<script filename>
@sqlplus.exe scott/tiger@testdb @browseUser.sql

Additionally, you can pass values to the script being run.

@sqlplus.exe <username>/<password>@<database name> @<script filename> <value 1> <value 2>
@sqlplus.exe scott/tiger@testdb @browseUser.sql TonyC Engineering

To reference the values passed in the script would look like this:

SELECT * FROM employees WHERE name = '&1' and dept = '&2';
Advertisements

From → Oracle

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: