Thursday, January 23, 2014

Oracle TWO_TASK Environment Variable

TWO_TASK variable is for Unix environment, there is a similar variable for Windows - LOCAL.

In the Unix environment there are 2 variables that are generally set to connect to a local database that resides on the same machine - the machine from which you are trying to connect:


ORACLE_HOME

ORACLE_SID

So, if you type 


vish> sqlplus username/password@mydb


or


vish> sqlplus username/password


Both will result in connecting to mydb - considering that the above 2 variables are pointing to mydb.


That was for your very own local database.


If you have to connect to a remote database, you have below options:


1.  TNS Names - Alias to a connect URL

2.  Typing in the entire Connect URL - the one that goes into TNS names file
3.  TWO_TASK variable

First two options you would already be familiar with - and anyways this article is about TWO_TASK so...


TWO_TASK - this is an environment variable so you can set its value similar to above 2 mentioned variables.


This variable expects the connect URL that goes into TNS names file.  For example:


TWO_TASK = <TNS Connect String>

TWO_TASK = (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=port))  (CONNECT_DATA=(SERVICE_NAME=service_name)))

And now when you type below command from your command prompt - it will directly connect to this remote database

vish> export TWO_TASK = <remotedb TNS Connect String>
vish> sqlplus username/password


So, TWO_TASK basically overrides ORACLE_SID parameter and would connect to Remote database that you have mentioned as a value of this variable.












Convert Java SQL String to Oracle SQL Format in TOAD

At times Toad might reset the capability to strip off / convert the the SQL in Java string format to SQL format. You can have that back...