Oracle Home path for 12c - oracle

I had 11g previously installed and now I have installed 12c. Have not uninstalled 11g.
The environment variable 'path' is set to 'bin' of 12c and oracle home is pointing to home i.e '11.2.0\server', of 11g.
It works but I want the Oracle_Home variable to be set to home of 12c. I do not find the path to server of 12c even after much research.
What is the path to 'home' of 12c?

You said,
"The environment variable 'path' is set to 'bin' of 12c"
It should be a path that looks something like
C:\app\oracle_account\product\12.1.0\somefolder\bin in windows
or
\u01\app\oracle\12.1.0\somefolder\bin in Unix/Linux
So, your Oracle 12c home should be
C:\app\oracle_account\product\12.1.0\somefolder or
\u01\app\oracle\12.1.0\somefolder\
Now, in windows, check the registry entry ( regedit )
HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_HOME_NAME
It should be set to the new oracle home discussed above otherwise change it or go to environment variables and set the ORACLE_HOME value.
Now, your PATH can be set using set PATH=%ORACLE_HOME%\bin;%PATH% to point to the correct bin directory.
For Unix, Linux you could export them correctly in the environment which you use to connect to the database.
export ORACLE_HOME='\u01\app\oracle\12.1.0\somefolder'

Related

Windows 10 pro x64, Oracle database 21c express edition: How to set ORACLE_HOME correct?

I am using Windows 10 pro x64, Oracle database 21c Express edition, Oracle SQL Developer 22.2.1 . How to set ORACLE_HOME correct?
I know this my setting was wrong (because sqlplus.exe cannot run/open with this system variable, I tried)
Is ORACLE_HOME
C:\app\Administrator\product\21c
C:\app\Administrator\product\21c\dbhomeXE
C:\app\Administrator\product\21c\homes
C:\app\Administrator\product\21c\homes\OraDB21Home1
?
Please guide me set ORACLE_HOME correctly!
On Windows you don't need to explicitly set an Oracle Home because we can work it out from the registry and the PATH.
But if you want to set an ORACLE_HOME its the parent folder of the 'bin' directory. Thus if sqlplus was found in C:\app\Administrator\product\21c\homes\OraDB21Home1\bin then your ORACLE_HOME would be C:\app\Administrator\product\21c\homes\OraDB21Home1
If you're running multiple versions/installations of Oracle (as I do), I'll often create a little batch file for each version,eg
sql19.cmd
=========
set ORACLE_SID=db19
set ORACLE_HOME=C:\oracle\product\19
set PATH=C:\oracle\product\19\bin;%PATH%
sqlplus scott/tiger#db19_pdb1
sql21.cmd
=========
set ORACLE_SID=db21
set ORACLE_HOME=C:\oracle\product\21
set PATH=C:\oracle\product\21\bin;%PATH%
sqlplus scott/tiger#db21_pdb1
and so on

Determining location of relevant tnsnames.ora file

I installed both the 32 and 64-bit Oracle 11g drivers. I search my PC looking for files with the name "tnsnames.ora" and found 3 in the following locations:
1. C:\Oracle\product\11203_32bit\CLIENT_1\NETWORK\ADMIN
2. C:\Oracle\product\11203_64bit\CLIENT_1\NETWORK\ADMIN
3. C:\Windows\TNS
The existence of the 3rd location of the tnsnames.ora file surprises me.
I have the following Oracle clients installed on my PC:
"C:\Program Files (x86)\Quest Software\Toad for Oracle 11.6\Toad.exe"
"C:\Program Files\Devart\dbForge Studio Express for Oracle\dbforgeoracle.exe"
Based on the location of each program (Program Files (x86) vs. c:\Program Files), This suggests to me that the Toad, a 32 bit program, should use the 32 bit driver and dbForge should use the 64 bit driver.
dbForge seems to use either the tnsnames.ora file in either location #2 or #3. I know this by systematically renaming all but one of the tns files and then checking to see if the connection names read from the file are available when trying to create a new connection from with the app.
However, TOAD seems to only recognize the tnsnames.ora file in location #3 and it did not recognize the tnsnames.ora file in location 2 at all! (Being that it was a 32 bit program, I did not expect it to recognize the tns file in location 2 and that was the case). TO summarize the TOAD test for the sake of hopeful clarity, TOAD only recognized the tns file in location 3.
Other colleagues do not have a tns file in location 3 on their machines. I'm not sure why I do. When I run Toad, it shows the following 2 Home, with the 32 bit Home as being the active one.
OraClient11g_home1 (11.2.0.3)
ORACLE_HOME:C:\app\C39293\product\11.2.0\client_1
ORACLE_HOME_NAME:OraClient11g_home1
ORACLE_HOME_KEY:HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraClient11g_home1
ORACLE_SID:
NLS_LANG:AMERICAN_AMERICA.WE8MSWIN1252
SQLPATH:
LOCAL:
Client DLL:C:\app\C39293\product\11.2.0\client_1\oci.dll
TNSNames.ora:
SQLNet.ora:
LDAP.ora:
Login.sql:
GLogin.sql:
In system PATH:No
Home is valid:No
OraClient11g_home1_32bit (11.2.0.3)
ORACLE_HOME:c:\oracle\product\11203_32bit\CLIENT_1
ORACLE_HOME_NAME:OraClient11g_home1_32bit
ORACLE_HOME_KEY:HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraClient11g_home1_32bit
ORACLE_SID:
NLS_LANG:AMERICAN_AMERICA.WE8MSWIN1252
SQLPATH:c:\oracle\product\11203_32bit\CLIENT_1\dbs
LOCAL:
Client DLL:c:\oracle\product\11203_32bit\CLIENT_1\bin\oci.dll
TNSNames.ora:
SQLNet.ora:
LDAP.ora:
Login.sql:
GLogin.sql:c:\oracle\product\11203_32bit\CLIENT_1\sqlplus\admin\glogin.sql
In system PATH:Yes
Q1: Is OraClient11g_home1 my 64 bit home or do I have two Oracle clients installed?
Q2: Why doesn't 32 bit TOAD use the tns in location #1 instead of only using the one in location #3?
Q3: If I leave on the tns file in location 3, both dbForge and TOAD work but I'd like to know why so I can accurately understand how to move tns info from one machine to another.
According Oracle these locations are searched for tnsnames.ora, resp. sqlnet.ora and ldap.ora:
Oracle Net files in present working directory (PWD/CWD)
TNS_ADMIN defined sessionally or by user-defined script
TNS_ADMIN defined as a global environment variable
TNS_ADMIN defined in the registry
Oracle Net files in %ORACLE_HOME/network|net80\admin (Oracle default location)
However, I am not sure whether each application/driver follows this list. I got this list from Oracle Document 111942.1 referring to Oracle 9i, so it might be outdated.
In Database Net Services Administrator's Guide the order is
TNS_ADMIN defined by environment variable
TNS_ADMIN defined in the registry (if TNS_ADMIN environment variable is not present)
%ORACLE_HOME%/network/admin directory (if TNS_ADMIN environment variable is not present)
I would recommend to define an environment variable for TNS_ADMIN and use only one tnsnames.ora file. In order to be on the safe side, check also your registry values.
If your files are not located in %ORACLE_HOME%\network\admin, I recommend to create a symbolic link for it - just to be on the very safe side, e.g. mklink /d %ORACLE_HOME%\network\admin c:\Oracle\common\settings\admin
Another note, you don't have to "play" with your tnsnames.ora file. With Process Monitor from Microsoft Sysinternals you can monitor each file access, i.e. the filter would be Path contains tnsnames
Update
When I run a test on my machine I get following order:
Environment variable TNS_ADMIN
Registry Key HKEY_CURRENT_USER\SOFTWARE\ORACLE\KEY_{Oracle_Home_Name}\TNS_ADMIN
Registry Key HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_{Oracle_Home_Name}\TNS_ADMIN, resp. HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ORACLE\KEY_{Oracle_Home_Name}\TNS_ADMIN
-> Only if TNS_ADMIN Environment variable is not set.
%ORACLE_HOME%\network\admin
Current directory (which can be different to directory where your application is located)
Folder where your application is located
Update 2
Obviously there is no fix search, it varies for different providers/drivers. Maybe it also depends on the Oracle version.
For example, the Oracle HTTP Server reads TNS_ADMIN setting from opmn.xml config file.
Another example, for ODP.NET Managed Driver (Oracle.ManagedDataAccess) beta version, I found this order at Oracle Managed and TNS Names :
data source alias in the 'dataSources' section under <oracle.manageddataaccess.client> section in the .NET config file (i.e. machine.config, web.config, user.config).
data source alias in the tnsnames.ora file at the location specified by TNS_ADMIN in the .NET config file.
data source alias in the tnsnames.ora file present in the same directory as the .exe.
data source alias in the tnsnames.ora file present at %TNS_ADMIN%
(where %TNS_ADMIN% is an environment variable setting).
data source alias in the tnsnames.ora file present at %ORACLE_HOME%\network\admin
(where %ORACLE_HOME% is an environment variable setting).
In official documentation (12c Release 4 (12.1.0.2.4)) it says:
data source alias in the dataSources section under <oracle.manageddataaccess.client> section in the .NET config file (i.e. machine.config, web.config, user.config).
data source alias in the tnsnames.ora file at the location specified by TNS_ADMIN in the .NET config file. Locations can consist of either absolute or relative directory paths.
data source alias in the tnsnames.ora file present in the same directory as the .exe.
However, based on some tests I made with ODP.NET Managed Driver (4.121.2.0) it takes %ORACLE_HOME%\network\admin and TNS_ADMIN Environment variable into account. Locks like the documentation is not 100% correct.
Just based on your paths you have two installed clients as you suspect (Toad and dbforge are tools, not clients so your terminology is a bit off). One 32-bit, the other 64-bit. It appears that Toad is 32-bit based on its installation path, but execute it and go to Help|Support Bundle. You'll see the top header will be "APPLICATION INFORMATION (32-bit)" or "APPLICATION INFORMATION (64-bit)" just to confirm. Toad 11.6 was the first to introduce a 64-bit version.
Toad will only see the Oracle client that is for the same platform as it. So your 64-bit client is irrelevant for Toad's sake. The C:\Windows\TNS appears to be a folder used for TNS_ADMIN folder given its odd location and the fact that Toad sees it. At command prompt execute SET TNS_ADMIN and see if it reports "TNS_ADMIN=C:\Windows\TNS" If it does, then all Tools should be using that tnsnames.ora. That's a global override if you will that points to the folder containing your net configuration files. If you don't have TNS_ADMIN set as an environment variable then look for it in your Oracle root registry: HKEY_LOCAL_MACHINE\Software\Oracle.
If you use a common set of connections for all of your tools I'd delete all of your tnsnames.ora files. I'd also relocate that C:\Windows\TNS folder to somewhere more appropriate like C:\Oracle\Admin and create your tnsnames.ora, sqlnet.ora, and ldap.ora (if applicable) there. Create a TNS_ADMIN environment variable pointing to that location.
In case you are using Visual Studio v2017 here is tnsNames File:
32 bits installation:
c:\program files (x86)\oracle developer tools for
vs2017\network\admin\tnsnames.ora
64 bits installation:
c:\program files\oracle developer tools for
vs2017\network\admin\tnsnames.ora

Can't find SQLPATH registry entry Oracle 11.2 Express

I'm trying to start working through Tom Kyte's book, "Expert Oracle Database Architecture" and have run into a snag. Tom recommends creating a custom login.sql script and briefly mentions setting the SQLPATH environment variable.
I've been following the instructions found here: http://docs.oracle.com/cd/B28359_01/server.111/b31189/ch2.htm#i1133354
I've searched for the SQLPATH and HOME0 keys, and for the ORACLE_HOME\DBS value, but it doesn't seem to exist in the Registry. I have Oracle 11.2 Express, Windows 8, and my Oracle instance name is the default, XE. In the Registry, I see
HKEY_LOCAL_MACHINE
SOFTWARE
ORACLE
KEY_XE
...
ORACLE_HOME (value: C:\oraclexe\app\oracle\product\11.2.0\server)
ORACLE_HOME_KEY
ORACLE_HOME_NAME
...
ODE
...
OLEDB
...
ODP.NET
2.112.2.0\
4.112.2.0\
OracleMTSRecoveryService
Protid_0
Setup
All Versions
1\
Current Version\
Is it possible that the SQLPATH variable is no longer created by default, and that I need to just create a new one? If so, exactly where should it exist? If not, then what?
SQLPATH is a Windows system-or user environment variable not found under KEY_XE.
You can set the SQLPATH like this: Right-click on "Computer" -> Properties -> Advanced Settings - Environment
me#XE>host set SQLPATH
SQLPATH=c:\projects\oracle\sqlplus
-- verification
me#XE>#[%SQLPATH%]
SP2-0310: unable to open files "[c:\projects\oracle\sqlplus].sql
Bjarte

Warning: oci_connect(): ORA-12705: Cannot access NLS data files or invalid environment specified

I Have been getting this error. I don't think I am getting anywhere with it.
I am using Instant Client 11.2.0.1 and trying to connect to a remote Oracle 9.2 database. Here is what I have tried:
Unzipped the Oracle Client in c:\oracle\ and set the path accordingly
Added a new environment variable NLS_LANG and set it to AMERICAN_AMERICA.WE8MSWIN1252
Re-booted the system after setting the environment variable
Renamed the NLS_LANG value in the ORACLE_HOME directory
Any help would be greatly appreciated.

Export from Oracle 10g database with 11g client - detailed

Database Version : 10g Enterprise Edition Release 10.2.0.4.0
Client Version: 11g Enterprise Edition Release 11.2.0.1.0 (windows 7 64bit)
When I try to export (exp) a table from database:
exp usr/pass#remote_db file=f.dmp tables=table
I get the following error:
EXP-00008: ORACLE error 904 encountered
ORA-00904: "POLTYP": invalid
identifier EXP-00000: Export terminated unsuccessfully
I know this question was answered earlier (the answer is "install 10g client to use its exp utility"), but I still didn't understand correctly:
Is Oracle 10g client 10.2.0.4 is ok for this? Do I need to setup TNS etc?
If I use the previous command to export the DB will the system automatically use the Ora10g client exp tool?
1) Yes, the 10.2.0.4 client would be OK. Yes, assuming that you use a tnsnames.ora file to connect to the database, you would need to configure a tnsnames.ora file in the Oracle Home for the newly installed 10.2.0.4 client or set the TNS_ADMIN environment variable to point at a single tnsnames.ora file for all Oracle Homes on the server. If you don't use a tnsnames.ora file to connect to the database, you would not need to configure one.
2) The command you posted will use the operating system's name resolution logic to determine which executable to invoke. Generally, that will be the executable in whichever Oracle Home is first in the operating system's PATH environment variable. Of course, you could specify an explicit path or change the current directory to the %Oracle Home%\bin of the 10.2.0.4 Oracle Home if that home was not first in the path.

Resources