[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 978
  • Last Modified:

how to connect to Oracle by cmd script

I have a set of sql scripts to go to oracle instance database. I have a .cmd files with all the sql script. I have an oracle database in local Windows XP machine

How to connect to oracle? How to write the connection string?
  • 2
2 Solutions
wasabi3689Author Commented:
Does someone understand what the following mean


If I have  a sever name : John
and Oracle instance name : ABC
and user name: sys
password: xxxx

So, how to write the connection statement to oracle in cmd.file?
slightwv (䄆 Netminder) Commented:
Normally in Windows you have the sql commands in another file like myscript.sql

Then use sqlpus to execute it:
sqlplus username/password@ABC @myscript.sql
slightwv (䄆 Netminder) Commented:
>>Does someone understand what the following mean

I Missed this.  This is just setting local variables to the script command line arguments.

using the same sqlplus and your variables:
sqlplus %_DATABASE_SECURITY% @myscript.sql
Gerwin Jansen, EE MVETopic Advisor Commented:

%1 = username
%2 = password
%3 = database

In case you would want to specify your script as a parameter as well, your script could look like this:

set _SCRIPT=%4

and call it like this:

runsql.cmd <user> <password> <database> <scriptname>

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now