Home > Enterprise >  How to startup automatically Oracle 19C using bash scripting and SQL PLUS?
How to startup automatically Oracle 19C using bash scripting and SQL PLUS?

Time:12-29

I've tried to create a bash script for connecting to my Oracle 19C database using sqlplus, I added the following code (which works also) :

#! /bin/sh.
connectsqlplus(){
    sqlplus "'"sys/mypassword as sysdba"'" 
EOF 
}
connectsqlplus

The main problem is that I want to use this bash script to start the database, what I've created seems to only let me open the sqlplus terminal, I just want to add the SQL> startup so that the database starts but I'm not really sure how to add this command in the SQL terminal by using bash scripting.

Any help would be much appreciated ! Thank you .

CodePudding user response:

#start_oracle_db.sh
ORACLE_SID=nameofyourdatabaseasrecordedinoratabfile
ORAENV_ASK=NO
source oraenv
sqlplus << EOF
connect / as sysdba
startup
exit
EOF
  • Related