Solved

Connecting to a database via ksh script

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

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 74

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AWK: Pythagoras script 6 37
subtr returning incorrect value 8 70
AWK:  END { statements } 2 27
Renaming with batch file 9 80
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

733 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