Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Vishal .

Asked: May 02, 2000 - 1:20 pm UTC

Last updated: July 27, 2007 - 8:25 am UTC

Version:

Viewed 10K+ times! This question is

You Asked

what is the use of TWO_TASK environment variable ?
where can we use it ?



and we said...



If you are in a Unix environment, you can normally set 2 environment variables:

ORACLE_HOME
ORACLE_SID

that will connect you to a local database identified by that home and sid. If you wanted to be able to connect to a remote database or a database on that machine via SQLNet, you can also set:

TWO_TASK = <tnsconnect string>


The setting of TWO_TASK overrides the ORACLE_SID when set. You will not connecting to a local database with two_task but rather using sqlnet to connect to a remote database.

So, instead of:

$ sqlplus scott/tiger@some_db

I can:

$ setenv TWO_TASK some_db
$ sqlplus scott/tiger

and the @some_db is implied.


Rating

  (8 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

connect string

Reader, December 05, 2003 - 11:09 am UTC

Tom, In the above example, some_db should have been resolved using tnsnames.ora on the box from which we connect to the remote database. Is it correct? Thanks.

Tom Kyte
December 05, 2003 - 11:27 am UTC

yes, the "local machine"

it could come from a variety of sources on that machine

~/.tnsnames.ora
$ORACLE_HOME/network/admin/tnsnames.ora
/var/opt/oracle/tnsnames.ora
$TNS_ADMIN/tnsnames.ora

for example

tnsnames_production.serv_name

mike, December 05, 2003 - 4:48 pm UTC

I have inherited:
Sun Solaris, Oracle8174.
Under $ORACLE_HOME/network/admin/
there are tnsnames.ora and the tnsnames_production.server_name. the server_name is another server machine. I have found Oracle also uses "tnsnames_production.server_name"
How this could happen?



Thanks

Mike





Tom Kyte
December 06, 2003 - 8:54 am UTC

does your tnsnames.ora have an ifile command in it?

That's it! thanks!

A reader, December 06, 2003 - 10:25 am UTC


Why does it not work when ORACLE_HOME is a softlink

Tommy Petersen, March 02, 2007 - 3:25 pm UTC

When I do set TWO_TASK or ORACLE_SID, they are not used if my directory for ORACLE_HOME is a softlink. I have updated my ORACLE_HOME to use the real directory name and it works.

We run on Sun Solaris.

Tom Kyte
March 04, 2007 - 6:29 pm UTC

why does what not work exactly? and what does not work mean?

Why such obscure name - TWO_TASK

A reader, March 05, 2007 - 10:37 am UTC

Why TWO?
Why Task?

Thanks, Jan
Tom Kyte
March 05, 2007 - 2:15 pm UTC

because in days gone by - the 1980's - two tasks (having two tasks working together) just made 'sense'

Just like "modular code" and "subroutine" used to be commonly used... :)

What does not work?

Tommy Petersen, March 05, 2007 - 11:17 am UTC

Sorry, I should have been more specific.
My export does not work when I set ORACLE_SID and using a softlink as ORACLE_HOME.
I get the following errors:
EXP-00056: ORACLE error 1034 encountered
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
SVR4 Error: 2: No such file or directory

Tom Kyte
March 05, 2007 - 2:27 pm UTC

you have to use the same ORACLE_HOME + ORACLE_SID with export as you used to start the database with.

we generate the key for the shared memory as a function of the oracle_home+oracle_sid


If you used the "soft linked" oracle_home as the oracle_home when you type startup - then it would work (but the real oracle home would not work)

listener could not resolve SERVICE_NAME

Vikash, July 26, 2007 - 1:49 am UTC

Hi ,

When I am trying to connect Oracle using ODBC I am getting this in listener.log * my app gives error .. DB conn failed(Invalid service name)..

(CONNECT_DATA=(SERVICE_NAME=192.168.0.13)(CID=(PROGRAM=cubadmserv.odbc")(HOST=Amit)(USER=root))) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.0.13)(PORT=34089)) * establish * 192.168.0.13 * 12514
TNS:listener could not resolve SERVICE_NAME given in connect descriptor

Vikash
Tom Kyte
July 27, 2007 - 8:25 am UTC

umm, well - the message seems to say it all.


the service name you used in your tnsnames.ora on the client was not able to be resolved on the server - the listener you connected to did know what that service was.


if you have lsnrctl - use it to connect to that listener and list the services.

Secure password store

Edgar, February 07, 2011 - 9:19 am UTC

Unfortunately, TWO_TASK does not work together with "secure password store" (10g,11g).
If secure password store is configured using mkstore, you can use
$ sqlplus /@tnsalias
to connect to the remote database without a password.
But You cannot do
$ export TWO_TASK=tnsalias
$ sqlplus /