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
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Integrating Redis With Message Brokers
  • Terraform State File: Key Challenges and Solutions
  • How to Reorganize and Rebuild Indexes in MS SQL?
  • Essential GitHub Enterprise Admin Commands

Trending

  • Immutable Secrets Management: A Zero-Trust Approach to Sensitive Data in Containers
  • Understanding IEEE 802.11(Wi-Fi) Encryption and Authentication: Write Your Own Custom Packet Sniffer
  • Cookies Revisited: A Networking Solution for Third-Party Cookies
  • Ethical AI in Agile
  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
10.6K 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

  • Integrating Redis With Message Brokers
  • Terraform State File: Key Challenges and Solutions
  • How to Reorganize and Rebuild Indexes in MS SQL?
  • Essential GitHub Enterprise Admin Commands

Partner Resources

×

Comments
Oops! Something Went Wrong

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

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!