Skip to Main Content
  • Questions
  • Executing OS commands from PLSQL code


Question and Answer

Chris Saxon

Thanks for the question, Ik.

Asked: February 28, 2017 - 8:11 am UTC

Answered by: Chris Saxon - Last updated: February 28, 2017 - 5:14 pm UTC

Category: Database - Version:

Viewed 10K+ times! This question is

You Asked


Is there a native Oracle solution to execute OS commands via PLSQL or SQL? I searched on the web and do not find an easy or straight forward technique. Can you please help?

Assuming OS is Linux and the command to execute is any executable or a tool, say srvctl.


and we said...

There are a few ways you can achieve this. You could write a Java stored procedure to accept and run commands:

Or use DBMS_pipe to send commands to a daemon running on the server:

Or use DBMS_scheduler to run OS commands (10g and up):

Whichever approach you take, be careful. Ensure you can't run commands like "rm -rf *" as a privileged OS user from PL/SQL!

Is this answer out of date? If it is, please let us know via a Review

More to Explore


More on PL/SQL routine DBMS_PIPE here