DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • 7 Techniques That Supercharged My Claude-Assisted Development
  • Beyond Request-Response: Architecting Stateful Agentic Chatbots with the Command and State Patterns
  • A Beginner's Guide to Docker Compose
  • A Beginner's Guide to Essential Commands to Fix Container Setup Issues

Trending

  • Setting Up Claude Code With Ollama: A Guide
  • The Prompt Isn't Hiding Inside the Image
  • How AI Coding Assistants Are Changing Developer Flow
  • Vercel AI SDK Middleware vs Genkit Middleware: A Hands-On Comparison
  1. DZone
  2. Data Engineering
  3. Databases
  4. Run Oracle SQL Script From Command Line in Windows

Run Oracle SQL Script From Command Line in Windows

Sometimes we have to run a particular SQL script from the Windows command line “CMD” with or without parameters. Here are the steps required to perform this task.

By 
Hassan Abd Elrahman user avatar
Hassan Abd Elrahman
·
Sep. 16, 21 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
11.8K Views

Join the DZone community and get the full member experience.

Join For Free

Sometimes we need to run a particular SQL script from the Windows command line “CMD” with or without parameters.

This article will guide you through the steps required to perform this task to get an employee’s information — both with and without parameters.

To Run SQL Scripts from Windows Command Line CMD 

  1. Press Windows + R from your keyboard, then type cmd and press enter.
Run SQL Script From Windows Command Line CMD Step 1
  1. Change the current directory to the directory where your script is available.
Run SQL Script From Windows Command Line CMD Step 2


  1. To run SQL Script without parameters, we need to type this command.
sqlplus hr/hr @ScriptWithoutParameter.sql
  1. To run SQL Script with parameters, we need to type this command.
sqlplus hr/hr @ScriptWithoutParameter.sql 101

It is important that when running SQL script with parameters from CMD:

  • In our script, the WHERE condition should be typed in the substitution variable as follows
select * from EMPLOYEES where employee_id = &1;
  • For the script above, we passed &1 to be replaced with 101 to bring employee number 101's data.

To Run SQL Script from SQL PLUS

  1. Open SQL PLUS and then connect to the database.
  2. In SQL Command, type the following command and press enter
oracle user:\MyScript\ScriptWithoutParameter.sql


SQL Plus Command (computing)

Published at DZone with permission of Hassan Abd Elrahman. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • 7 Techniques That Supercharged My Claude-Assisted Development
  • Beyond Request-Response: Architecting Stateful Agentic Chatbots with the Command and State Patterns
  • A Beginner's Guide to Docker Compose
  • A Beginner's Guide to Essential Commands to Fix Container Setup Issues

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook