Connecting to multiple Oracle databases hosted on different machines - Username as common and different password for each database
0
votes
2
answers
570
views
Environment:
We have ~100 databases hosted on multiple machines. All databases have common username but password is different on every database.
Issue:
How can I read the password and TNS (Service name) from an external file one by one and connect to the each database and run the sql query and pass the output to a logfile.
What is done so far:
1. Created
pass
file that contains password and Service_Name and delimiter ":"
cat pass
Loufr#123:PROD
Brinj#6523:TEST
2. Another file dblist
is created with all the dbnames
(that matches the service names) in step 1
cat dblist
PROD
TEST
DEV
QA
Quality
-----------------------------------------
Goal:
read name of the database from dblist
and find the password from pass
file for that database.
Use dbname
and password
to connect to database in following string
sqlplus -s dbsnmp@${TNS}/${Password}
spool output.log
@query.sql
exit
Asked by Gaurav Gupta
(11 rep)
Sep 11, 2021, 05:20 PM
Last activity: Sep 16, 2021, 10:22 AM
Last activity: Sep 16, 2021, 10:22 AM