Solved

Connecting to a database via ksh script

Posted on 2013-06-10
4
1,200 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

863 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

28 Experts available now in Live!

Get 1:1 Help Now