Search code examples
oracleoracleclient

Referring external file in TNSORANAMES.ora


I am trying to write a VB script to add/edit/delete some entries in tnsnames.ora. It will be convenient to refer/modify an external file (say myProjectOraNames.ora) rather than modifying tnsnames.ora

With this configuration (assuming it is possible), the Oracle client should refer to both the existing tnsnames.ora file and my new myProjectOraNames.ora to get service details.

Is there any option/configuration can be done to achieve this functionality?


Solution

  • You can configure the primary tnsnames.ora file to use other files as well using the IFILE command.

    On my laptop, for example, I have separate tnsnames.ora files for various clients. So my tnsnames.ora file looks something like

    JCAVE11G.WORLD =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = <<ip address>>)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = jcave11gr2)
        )
      )
    
    
    IFILE = c:\oracle\product\11.1.0\db_1\Network\Admin\tnsnames.ora.client1
    IFILE = c:\oracle\product\11.1.0\db_1\Network\Admin\tnsnames.ora.client2
    IFILE = c:\oracle\product\11.1.0\db_1\Network\Admin\tnsnames.ora.client3
    

    You could do something similar where the primary tnsnames.ora file has an IFILE reference to your myProjectOraNames.ora file