admin 發表於 2019-12-2 12:13:12

Setting the TNS_ADMIN Environment Variable

The TNS_ADMINenvironment variable is used to specify the directory location for the tnsnames.ora file.
The TNS_ADMIN environment variable can be defined in the following ways:


1.       Access the Windows registry by clicking: StartRunregedit
2. Add the TNS_ADMIN environment variable to the HKEY_LOCAL_MACHINE\Software\Oracle\ORACLE_HOME key by right mouse clicking, and then selecting: NewKeyString Value

If you are unsure where to set TNS_ADMIN in the registry, see the ORACLE_HOME\bin\oracle.key file which provides the location of the registry key used by executables within that home.

Each time a different Oracle version is installed on Windows, the default location to which SQL*Net files are generated is the ORACLE_HOME\network\admin directory.

TNS_ADMIN may also be defined as a system-wide or global variable within the operating system.To do so:
1.      Logon as Administrator
2.      Click StartSettingsControl Panel
3.      Double click the SYSTEM icon
4.      From System Properties, select Environment tab
5.      Highlight OS in the list of Systems Variables
6.      Change the Variable from OS to TNS_ADMIN
7.      Change the Value to the file path where the configuration files will reside.   
         For example: c:\oranwin\network\admin.
8.      Click set, then apply
9.      Click OK to close window
    Changing TNS_ADMIN at the Session Level
For temporary usage, the TNS_ADMIN may also be defined for a given DOS prompt by using the set command:

C:\> set tns_admin=c:\temp

According to the docs, the precedence in which Oracle Net
                Configuration files are resolved is:               
                        [*] Oracle Net files in present working directory (PWD/CWD)
                        [*] TNS_ADMIN set for each session session or by a user-defined script
                        [*] TNS_ADMIN set as a global environment variable
                        [*] TNS_ADMIN as defined in the registry
                        [*] Oracle Net files in %ORACLE_HOME/network/admin
(Oracle default location)


頁: [1]
查看完整版本: Setting the TNS_ADMIN Environment Variable