WHAT ORACLE_HOME WAS USED TO START UP A DATABASE INSTANCE?
Environment Variables
A query to get the ORACLE_HOME path in an Oracle Database.
GOAL
I need to know from which ORACLE_HOME a database instance is running.
SOLUTION
DBMS_SYSTEM
-- Querying ORACLE_HOME with PL/SQL
COL ORACLE_HOME FOR A30
VARIABLE ORACLE_HOME VARCHAR2(100);
EXEC DBMS_SYSTEM.GET_ENV('ORACLE_HOME',:ORACLE_HOME);
PRINT ORACLE_HOME
ORACLE_HOME
------------------------------
/u01/app/oracle/product/19c
SYS_CONTEXT
-- Only applies to oracle 12c and higher
COL ORACLE_HOME FOR A30
SELECT SYS_CONTEXT ('USERENV','ORACLE_HOME') ORACLE_HOME FROM DUAL;
ORACLE_HOME
------------------------------
/u01/app/oracle/product/19c
SYS.V_$PARAMETER
-- Only applies if a spfile is being used
COL ORACLE_HOME FOR A30
SELECT DECODE(VALUE, NULL,
'UNABLE TO IDENTIFY ORACLE_HOME',
SUBSTR(VALUE, 1, INSTR(VALUE, '/', -1, 2) -1)
) ORACLE_HOME
FROM
SYS.V_$PARAMETER WHERE NAME='spfile';
ORACLE_HOME
------------------------------
/u01/app/oracle/product/19c
DBA_LIBRARIES
-- Only applies to version 12.2.0.1 and lower
-- For details see Doc ID 2145739.1
COL "ORACLE_HOME" FOR A30
SELECT NVL(SUBSTR(FILE_SPEC, 1, INSTR(FILE_SPEC, '\', -1, 2) -1),
SUBSTR(FILE_SPEC, 1, INSTR(FILE_SPEC, '/', -1, 2) -1)) "ORACLE_HOME"
FROM DBA_LIBRARIES WHERE LIBRARY_NAME = 'DBMS_SUMADV_LIB';
ORACLE_HOME
------------------------------
/oracle/product/12.2.0.1
REFERENCES
ORDIMLIBS and DBMS_SUMADV_LIB libraries use hard-coded Oracle Home path (Doc ID 2145739.1)
Written At
07 NOV 202112:10
OEL Release
7.9 x64
Database Release
19.12.0.0.0
Tags In
Share
- Accounts
- Auditing
- AWR
- Bash Scripts
- Datapump
- Default Category
- Demos
- Directory Objects
- Environment Variables
- Initialization Parameters
- Iptables
- Java Program
- Memory Usage
- Metadata API
- Networker
- NLS Settings
- Optimizer Statistics
- ORA-00942
- ORA-01031
- ORA-01720
- ORA-28001
- ORA-31671
- Oracle Database
- Oracle Enterprise Manager
- Performance Tunning
- Postfix
- Privilegies
- Processes
- Queries
- Red Hat Enterprise Linux
- Redo Logs
- Session Tracing
- Sessions
- SQL Trace
- SQLPlus
- Statspack
- Tablespaces
- UTL_FILE
- UTL_FILE_DIR
- Wait Events
- Yum