Solved

Connecting to a database via ksh script

Posted on 2013-06-10
4
1,176 Views
Last Modified: 2013-06-10
How can I check if a particular database is running on the server and then connect to it via sqlplus from aksh script?

I get an ORACLE_SID from oratab file but then I am stuck.

Should I use

. oraenv

to set the environment and then

sqlplus -s "/ as sysdba" << $OUTFILE

or are there better ways?

Can anyone help?
0
Comment
Question by:YZlat
  • 2
  • 2
4 Comments
 
LVL 73

Assisted Solution

by:sdstuber
sdstuber earned 500 total points
ID: 39235319
using oraenv is fine


connecting as sysdba is not recommended unless you're doing an install or upgrade that actually requires those privileges
0
 
LVL 35

Author Comment

by:YZlat
ID: 39235455
if I use . oraenv, how do i specify which ORACLE_SID to connect to?
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 total points
ID: 39235531
assuming you don't want to be prompted from within your script  set the SID and ASK variables first, then invoke oraenv

export ORACLE_SID=YOUR_DB_SID
export ORAENV_ASK=NO

.  oraenv

Open in new window

0
 
LVL 35

Author Closing Comment

by:YZlat
ID: 39235589
Thank you!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now