Sometimes we have a requirement to run a particular SQL script from windows command line “CMD” with or without parameters.
So that’s why we prepare this article to guide you through the steps required to perform this task to get all employee’s information that doesn’t need a parameter and another one to get a certain employee information.
To Run SQL Script from windows command line CMD :
- Press Windows + R from your keyboard, then type cmd and press enter.
- Change the current directory to the directory where your script is available.
- To run SQL Script without parameters, we need to type this command.
sqlplus hr/hr @ScriptWithoutParameter.sql
- To run SQL Script with parameters, we need to type this command.
sqlplus hr/hr @ScriptWithoutParameter.sql 101
Important note when running SQL script with parameter from cmd
- In our script, the where condition should be typed in substitution variable as follows
select * from EMPLOYEES where employee_id = &1;
- For the Above script, we passed &1 to be replaced with 101 to bring employee number 101 data.
To Run SQL Script from SQL PLUS follow this steps:
- Open SQL PLUS Screen and then connect to database
- In SQL Command type the following command and press enter
oracle user:\MyScript\ScriptWithoutParameter.sql
In this tutorial, you have learned how to run SQL Script from the windows command line with or without parameters.
Hopefully, it was clear and concise.
This piece of writing will assist the internet visitors
for building up new webpage or even a blog from start to end.