Oracle Deinstall
Deinstall (11.2 onwards)
opatch lsinventory -all | awk '/List of Oracle Homes:/,/Installed Top-level Products/'
export OHOME=/u01/app/oracle/product/12102 # Set as appropriate based on output from above
ls ${OHOME} # If the directory does not exist then Detach rather than Deinstall
export DINST=${OHOME}/deinstall
cd ${DINST}
./deinstall -checkonly -o ${DINST}/response
./deinstall -silent -paramfile ${DINST}/response/$(ls -rt ${DINST}/response | tail -1)
opatch lsinventory -all | awk '/List of Oracle Homes:/,/Installed Top-level Products/' # Deinstalled Home should be gone
Detach
You would most likely need to use Detach if you discover an Oracle Home in the Inventory that does not exist on disk.Set ORACLE_HOME to your current environment (tested with 12.2) irrespective of the version you wish to detach...
opatch lsinventory -all | awk '/List of Oracle Homes:/,/Installed Top-level Products/'
export OHOME=/u01/app/oracle/product/10.2.0 # Set as appropriate based on output from opatch
export ONAME=ORAHome # Set as appropriate based on output from opatch
ls ${OHOME} # If the directory exists then Deinstall rather than Detach
${ORACLE_HOME}/oui/bin/runInstaller -silent -detachHome ORACLE_HOME="${OHOME}" ORACLE_HOME_NAME="${ONAME}"
opatch lsinventory -all | awk '/List of Oracle Homes:/,/Installed Top-level Products/'
Backout
If you accidentally Detach an Oracle Home directory that exists, you can backout using...
${ORACLE_HOME}/oui/bin/runInstaller -silent -ignoreSysPrereqs -attachHome ORACLE_HOME="${OHOME}" ORACLE_HOME_NAME="${ONAME}" CLUSTER_NODES="{}"
Deinstall (11.1 and prior)
Set Oracle environment to match the ORACLE_HOME to be removed.
Run each command separately to be sure variables are correct before invoking runInstaller.opatch lsinventory -all | awk '/List of Oracle Homes:/,/Installed Top-level Products/'
export OHOME=/u01/app/oracle/product/10.2.0 # Set as appropriate based on output from opatch
opatch lsinventory | grep "^Oracle Database" | head -1
export OVERS=$(opatch lsinventory | grep "^Oracle Database" | head -1 | awk '{ print $4 }')
cd $ORACLE_HOME/oui/bin
./runInstaller -silent -debug -deinstall DEINSTALL_LIST='{"oracle.server","${OVERS}"}' REMOVE_HOMES={"${OHOME}"}
Set Oracle environment to the current ORACLE_HOME
You will be unable to run opatch from the deinstalled Oracle Home since all files have been deletedopatch lsinventory -all | awk '/List of Oracle Homes:/,/Installed Top-level Products/'
Remember to Delete/Update any .profile files or scripts that refer to the deinstalled ORACLE_HOME