0

I would like to connect to a ORACLE database via SQLplus. If I do it this way:

sqlplus "user/pw@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
(HOST=dbsrv01.desy.de)(PORT=1521))(ADDRESS=(PROTOCOL = TCP)(HOST = dbsrv02.desy.de)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = 
dbsrv03.desy.de)(PORT = 1521))(LOAD_BALANCE = yes)(CONNECT_DATA 
=(SERVER = DEDICATED)(SERVICE_NAME = desy_db.desy.de)(FAILOVER_MODE 
=(TYPE = NONE)(METHOD = BASIC)(RETRIES = 180)(DELAY = 5))))

it works fine.

But it's kind of annoying to connect with such a long URL. If I try to use a Variable instead of the string, its not working:

sqlplus user/pw@rac

Can I somehow connect to the database without using this long URL over and over again?

This is the value of my variable:

export rac="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
(HOST=dbsrv01.desy.de)(PORT=1521))(ADDRESS=(PROTOCOL = TCP)(HOST = dbsrv02.desy.de)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = 
dbsrv03.desy.de)(PORT = 1521))(LOAD_BALANCE = yes)(CONNECT_DATA 
=(SERVER = DEDICATED)(SERVICE_NAME = desy_db.desy.de)(FAILOVER_MODE 
=(TYPE = NONE)(METHOD = BASIC)(RETRIES = 180)(DELAY = 5))))"

I saved the variable in the bash.bashrc. If I echo her, it give the correct value back.

I use Ubuntu 14.04.

Or am I caught on the wrong road? Thanks for help ;-)

0

Okay, I'm sorry, didn't saw that there already is a variable for what I wanted to do: https://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_two.htm#i1133354 Just set the TWO_TASK variable with my URL and was able to connect to the db with:

sqlplus user/pw

Have a nice day, sir's!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.