-1

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 .

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
Bob950
  • 5
  • 3
  • https://docs.oracle.com/cd/E17781_01/server.112/e18804/startup.htm#ADMQS124 – astentx Dec 27 '21 at 22:12
  • From bash script I asked, not from the SQLPLUS command line which opens after I enter the code and execute the script from above. – Bob950 Dec 27 '21 at 22:22
  • Then https://stackoverflow.com/questions/10277983/connect-to-sqlplus-in-a-shell-script-and-run-sql-scripts – astentx Dec 28 '21 at 05:58

1 Answers1

3
#start_oracle_db.sh
ORACLE_SID=nameofyourdatabaseasrecordedinoratabfile
ORAENV_ASK=NO
source oraenv
sqlplus << EOF
connect / as sysdba
startup
exit
EOF
EdStevens
  • 3,708
  • 2
  • 10
  • 18