Saturday, June 13, 2015

How to deinstall or remove Oracle Database Software (Binaries) from server/machine/laptop!

Here I have showed in Windows but you can use same steps for Linux or Unix etc.

Summary :

Please open CMD as a Administrator (right button click on CMD icon then Open as a Administrator)

1) Go to the Oracle_home path or directory 
          Example of oracle_home dir,  C:\app\product\11.2.0\db_1\

like :   CMD> cd  C:\app\product\11.2.0\db_1    (enter)
 
2) Go to deinstall folder like below 

         C:\app\product\11.2.0\db_1>  deinstall  (enter)

3) Execute the deinstall  ( windows batch file) like below 

         C:\app\product\11.2.0\db_1\deinstall> deinstall     (enter)

4) Then follow instruction and proceed

5) After execution the script, restart the machine the remove the oracle installation folders .

Practical example: -

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Windows\system32>
C:\Windows\system32>
C:\Windows\system32>cd C:\app\product\11.2.0\db_1\deinstall

C:\app\product\11.2.0\db_1\deinstall>
C:\app\product\11.2.0\db_1\deinstall>
C:\app\product\11.2.0\db_1\deinstall>deinstall
Checking for required files and bootstrapping ...
Please wait ...
14 File(s) copied
610 File(s) copied
1 file(s) copied.
1 file(s) copied.
Location of logs C:\Users\my\AppData\Local\Temp\OraDeinstall2015-06-13_12-59-45\
logs\

############ ORACLE DEINSTALL & DECONFIG TOOL START ############


######################## CHECK OPERATION START ########################
Install check configuration START


Checking for existence of the Oracle home location C:\app\product\11.2.0\db_1
Oracle Home type selected for de-install is: SIDB
Oracle Base selected for de-install is: C:\app
Checking for existence of central inventory location C:\Program Files\Oracle\Inv
entory

Install check configuration END

Checking Windows and .NET products configuration START


The following Windows and .NET products will be deconfigured from the Oracle hom
e : asp.net,ode.net,odp.net,ntoledb,oramts

Checking Windows and .NET products configuration END


Network Configuration check config START

Network de-configuration trace file location: C:\Users\my\AppData\Local\Temp\Ora
Deinstall2015-06-13_12-59-45\logs\netdc_check3782178887990698751.log

Specify all Single Instance listeners that are to be de-configured [LISTENER]:

Network Configuration check config END

Database Check Configuration START

Database de-configuration trace file location: C:\Users\my\AppData\Local\Temp\OraDeinstall2015-06-13_12-59-45\
logs\databasedc_check1200720910770180178.log

Use comma as separator when specifying list of values as input

Specify the list of database names that are configured in this Oracle home [HALIMDB]:

###### For Database 'HALIMDB' ######

Single Instance Database
The diagnostic destination location of the database: C:\APP\diag\rdbms\halimdb
Storage type used by the Database: FS
Database file location: C:\APP\ORADATA\HALIMDB,C:\APP\FLASH_RECOVERY_AREA\HALIMDB
Flash recovery area location: C:\app\flash_recovery_area\HALIMDB
database spfile location: C:\APP\PRODUCT\11.2.0\DB_1\DATABASE\SPFILEHALIMDB.ORA

The details of database(s) HALIMDB have been discovered automatically. Do you still want to modify the details
of HALIMDB database(s)? [n]:

Database Check Configuration END

Enterprise Manager Configuration Assistant START

EMCA de-configuration trace file location: C:\Users\my\AppData\Local\Temp\OraDeinstall2015-06-13_12-59-45\logs
\emcadc_check.log

Checking configuration for database HALIMDB
Enterprise Manager Configuration Assistant END
Oracle Configuration Manager check START
OCM check log file location : C:\Users\my\AppData\Local\Temp\OraDeinstall2015-06-13_12-59-45\logs\\ocm_check32
69.log
Oracle Configuration Manager check END

######################### CHECK OPERATION END #########################


####################### CHECK OPERATION SUMMARY #######################
Oracle Home selected for de-install is: C:\app\product\11.2.0\db_1
Inventory Location where the Oracle home registered is: C:\Program Files\Oracle\Inventory
The following Windows and .NET products will be deconfigured from the Oracle home : asp.net,ode.net,odp.net,nt
oledb,oramts
Following Single Instance listener(s) will be de-configured: LISTENER
The following databases were selected for de-configuration : HALIMDB
Database unique name : HALIMDB
Storage used : FS
Will update the Enterprise Manager configuration for the following database(s): HALIMDB
No Enterprise Manager ASM targets to update
No Enterprise Manager listener targets to migrate
Checking the config status for CCR
Oracle Home exists with CCR directory, but CCR is not configured
CCR check is finished
Do you want to continue (y - yes, n - no)? [n]: y
A log of this session will be written to: 'C:\Users\my\AppData\Local\Temp\OraDeinstall2015-06-13_12-59-45\logs
\deinstall_deconfig2015-06-13_01-00-08-PM.out'
Any error messages from this session will be written to: 'C:\Users\my\AppData\Local\Temp\OraDeinstall2015-06-1
3_12-59-45\logs\deinstall_deconfig2015-06-13_01-00-08-PM.err'

######################## CLEAN OPERATION START ########################

Enterprise Manager Configuration Assistant START

EMCA de-configuration trace file location: C:\Users\my\AppData\Local\Temp\OraDeinstall2015-06-13_12-59-45\logs
\emcadc_clean.log

Updating Enterprise Manager Database Control configuration for database HALIMDB
Updating Enterprise Manager ASM targets (if any)
Updating Enterprise Manager listener targets (if any)
Enterprise Manager Configuration Assistant END
Database de-configuration trace file location: C:\Users\my\AppData\Local\Temp\OraDeinstall2015-06-13_12-59-45\
logs\databasedc_clean2337324818903439886.log
Database Clean Configuration START HALIMDB
This operation may take few minutes.
Database Clean Configuration END HALIMDB

Network Configuration clean config START

Network de-configuration trace file location: C:\Users\my\AppData\Local\Temp\OraDeinstall2015-06-13_12-59-45\l
ogs\netdc_clean1302827479082610407.log

De-configuring Single Instance listener(s): LISTENER

De-configuring listener: LISTENER
Stopping listener: LISTENER
Listener stopped successfully.
Deleting listener: LISTENER
Listener deleted successfully.
Listener de-configured successfully.

De-configuring Listener configuration file...
Listener configuration file de-configured successfully.

De-configuring Naming Methods configuration file...
Naming Methods configuration file de-configured successfully.

De-configuring Local Net Service Names configuration file...
Local Net Service Names configuration file de-configured successfully.

De-configuring backup files...
Backup files de-configured successfully.

The network configuration has been cleaned up successfully.

Network Configuration clean config END

Oracle Configuration Manager clean START
OCM clean log file location : C:\Users\my\AppData\Local\Temp\OraDeinstall2015-06-13_12-59-45\logs\\ocm_clean32
69.log
Oracle Configuration Manager clean END
Removing Windows and .NET products configuration START


Removing Windows and .NET products configuration END
Oracle Universal Installer clean START

Removing service 'OracleOraDb11g_home1ClrAgent' on the local node : Done

Detach Oracle home 'C:\app\product\11.2.0\db_1' from the central inventory on the local node : Done

Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oracell11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraclient11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oracommon11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oracore11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orageneric11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orahasgen11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraldapclnt11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oran11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orancds11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orancrypt11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oranhost11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oranl11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oranldap11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oranls11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orannzsbb11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oranro11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orantcp11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orantns11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraocr11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraocrb11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraocrutl11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraperf.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraperf11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraplp11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orapls11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\ORASLAX11.DLL'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orasnls11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orasql11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraunls11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orauts.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oravsn11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraxml11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orazt11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraztkg11.dll'. The file is in use.
Failed to delete the directory 'C:\app\product\11.2.0\db_1\BIN'. The directory is not empty.
Failed to delete the file 'C:\app\product\11.2.0\db_1\dbs\perf11.ora'. The file is in use.
Failed to delete the directory 'C:\app\product\11.2.0\db_1\dbs'. The directory is not empty.
Failed to delete the directory 'C:\app\product\11.2.0\db_1\deinstall'. The directory is in use.
Failed to delete the directory 'C:\app\product\11.2.0\db_1'. The directory is not empty.
Delete directory 'C:\app\product\11.2.0\db_1' on the local node : Failed <<<<

Delete directory 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Oracle - OraDb11g_home1' on the local n
ode : Done

Removing oracle home 'C:\app\product\11.2.0\db_1' from PATH variable on the local node : Done

Delete directory 'C:\Program Files\Oracle\Inventory' on the local node : Done

Delete directory 'C:\Program Files\Oracle' on the local node : Done

Delete Registry key 'HKEY_LOCAL_MACHINE\Software\Oracle\inst_loc' on the local node : Done

Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oracell11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraclient11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oracommon11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oracore11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orageneric11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orahasgen11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraldapclnt11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oran11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orancds11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orancrypt11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oranhost11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oranl11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oranldap11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oranls11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orannzsbb11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oranro11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orantcp11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orantns11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraocr11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraocrb11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraocrutl11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraperf.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraperf11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraplp11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orapls11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\ORASLAX11.DLL'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orasnls11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orasql11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraunls11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orauts.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oravsn11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraxml11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orazt11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraztkg11.dll'. The file is in use.
Failed to delete the directory 'C:\app\product\11.2.0\db_1\BIN'. The directory is not empty.
Failed to delete the file 'C:\app\product\11.2.0\db_1\dbs\perf11.ora'. The file is in use.
Failed to delete the directory 'C:\app\product\11.2.0\db_1\dbs'. The directory is not empty.
Failed to delete the directory 'C:\app\product\11.2.0\db_1\deinstall'. The directory is in use.
Failed to delete the directory 'C:\app\product\11.2.0\db_1'. The directory is not empty.
Failed to delete the directory 'C:\app\product\11.2.0'. The directory is not empty.
Failed to delete the directory 'C:\app\product'. The directory is not empty.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oracell11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraclient11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oracommon11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oracore11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orageneric11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orahasgen11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraldapclnt11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oran11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orancds11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orancrypt11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oranhost11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oranl11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oranldap11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oranls11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orannzsbb11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oranro11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orantcp11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orantns11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraocr11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraocrb11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraocrutl11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraperf.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraperf11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraplp11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orapls11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\ORASLAX11.DLL'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orasnls11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orasql11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraunls11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orauts.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oravsn11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraxml11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orazt11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraztkg11.dll'. The file is in use.
Failed to delete the directory 'C:\app\product\11.2.0\db_1\BIN'. The directory is not empty.
Failed to delete the file 'C:\app\product\11.2.0\db_1\dbs\perf11.ora'. The file is in use.
Failed to delete the directory 'C:\app\product\11.2.0\db_1\dbs'. The directory is not empty.
Failed to delete the directory 'C:\app\product\11.2.0\db_1\deinstall'. The directory is in use.
Failed to delete the directory 'C:\app\product\11.2.0\db_1'. The directory is not empty.
Failed to delete the directory 'C:\app\product\11.2.0'. The directory is not empty.
Failed to delete the directory 'C:\app\product'. The directory is not empty.
Failed to delete the directory 'C:\app'. The directory is not empty.
Delete directory 'C:\app' on the local node : Failed <<<<

Oracle Universal Installer cleanup completed with errors.

Oracle Universal Installer clean END


Oracle install clean START


Oracle install clean END

Moved default properties file C:\Users\my\AppData\Local\Temp\OraDeinstall2015-06-13_12-59-45\response\deinstal
l_OraDb11g_home1.rsp as C:\Users\my\AppData\Local\Temp\OraDeinstall2015-06-13_12-59-45\response\deinstall_OraD
b11g_home1.rsp4

######################### CLEAN OPERATION END #########################


####################### CLEAN OPERATION SUMMARY #######################
Updated Enterprise Manager configuration for database HALIMDB
Successfully de-configured the following database instances : HALIMDB
Following Single Instance listener(s) were de-configured successfully: LISTENER
Cleaning the config for CCR
As CCR is not configured, so skipping the cleaning of CCR configuration
CCR clean is finished
Removed asp.net configuration
Removed ode.net configuration
Removed odp.net configuration
Removed ntoledb configuration
Removed oramts configuration
Successfully removed service 'OracleOraDb11g_home1ClrAgent' on the local node.
Successfully detached Oracle home 'C:\app\product\11.2.0\db_1' from the central inventory on the local node.
Failed to delete directory 'C:\app\product\11.2.0\db_1' on the local node.
Successfully deleted directory 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Oracle - OraDb11g_home1'
on the local node.
Successfully removed oracle home 'C:\app\product\11.2.0\db_1' from PATH variable on the local node.
Successfully deleted directory 'C:\Program Files\Oracle\Inventory' on the local node.
Successfully deleted directory 'C:\Program Files\Oracle' on the local node.
Successfully deleted Registry key 'HKEY_LOCAL_MACHINE\Software\Oracle\inst_loc' on the local node.
Failed to delete directory 'C:\app' on the local node.
Oracle Universal Installer cleanup completed with errors.

Oracle install successfully cleaned up the temporary directories.
#######################################################################


############# ORACLE DEINSTALL & DECONFIG TOOL END #############

1 dir(s) moved.
1 dir(s) moved.
1 dir(s) moved.

C:\app\product\11.2.0\db_1\deinstall>
C:\app\product\11.2.0\db_1\deinstall>
C:\app\product\11.2.0\db_1\deinstall>




Then restarted the machine/server/laptop 

Then remove the oracle folders or drives using following steps

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Windows\system32>
C:\Windows\system32>
C:\Windows\system32>cd ..

C:\Windows>cd ..

C:\>
C:\>
C:\>rmdir /S app
app, Are you sure (Y/N)? y

C:\>
C:\>
C:\>

after removing the app folder all following files are removed.


Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\ORASLAX11.DLL'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orasnls11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orasql11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\oraunls11.dll'. The file is in use.
Failed to delete the file 'C:\app\product\11.2.0\db_1\BIN\orauts.dll'. The file is in use.



All are done, no Oracle binaries are here..... cheers . Thanks Halim.

Wednesday, June 10, 2015

ORA-02292: integrity constraint (constraint_name) violated - child record found

I know this is very simple thing but lot of time I am facing this question from newbies that's why this thread.

Solution for this error,  you have to drop your current foreign key constraint and create new one with  one of below options

ON DELETE SET NULL
or
ON DELETE CASCADE

but before applying that you have to understand your business domain. because ON DELETE CASCADE  will delete the referencing rows from that child tables and ON DELETE SET NULL will set a null value on that referencing column's rows.

Just a simple practical example-

CREATE TABLE FAMILY (FAMILY_ID NUMBER);


CREATE TABLE MEMBER
(
   MEMBER_ID   NUMBER,
   FAMILY_ID   NUMBER
);


-- Primary Key Constraints for Table FAMILY

ALTER TABLE FAMILY ADD (
  CONSTRAINT FAMILY_PK
  PRIMARY KEY
  (FAMILY_ID)
  ENABLE VALIDATE);


-- Foreign Key Constraints for Table MEMBER


ALTER TABLE MEMBER ADD (
  CONSTRAINT MEMBER_FAMILY_FK
  FOREIGN KEY (FAMILY_ID)
  REFERENCES FAMILY (FAMILY_ID)
  ENABLE VALIDATE);

INSERT INTO FAMILY (FAMILY_ID)
     VALUES (1);

INSERT INTO FAMILY (FAMILY_ID)
     VALUES (2);

INSERT INTO FAMILY (FAMILY_ID)
     VALUES (3);

INSERT INTO FAMILY (FAMILY_ID)
     VALUES (4);

INSERT INTO FAMILY (FAMILY_ID)
     VALUES (5);

COMMIT;


INSERT INTO MEMBER (MEMBER_ID, FAMILY_ID)
     VALUES (1, 1);

INSERT INTO MEMBER (MEMBER_ID, FAMILY_ID)
     VALUES (1, 1);

INSERT INTO MEMBER (MEMBER_ID, FAMILY_ID)
     VALUES (1, 1);

INSERT INTO MEMBER (MEMBER_ID, FAMILY_ID)
     VALUES (1, 5);

INSERT INTO MEMBER (MEMBER_ID, FAMILY_ID)
     VALUES (1, 5);

INSERT INTO MEMBER (MEMBER_ID, FAMILY_ID)
     VALUES (1, 5);

INSERT INTO MEMBER (MEMBER_ID, FAMILY_ID)
     VALUES (1, 3);

INSERT INTO MEMBER (MEMBER_ID, FAMILY_ID)
     VALUES (1, 3);

INSERT INTO MEMBER (MEMBER_ID, FAMILY_ID)
     VALUES (1, 3);

INSERT INTO MEMBER (MEMBER_ID, FAMILY_ID)
     VALUES (1, 2);

COMMIT;



DELETE FROM family  WHERE family_id = 5               ---it will generate an error
                        
                        



     ORA-02292: integrity constraint (CRIC.MEMBER_FAMILY_FK) violated - child record found



Solution:-

1) drop foreign key (before drop please please backup the old script if your are not sure about relationship )


ALTER TABLE MEMBER
   DROP CONSTRAINTS MEMBER_FAMILY_FK


2) create like below


 ALTER TABLE MEMBER
 ADD (CONSTRAINT MEMBER_FAMILY_FK FOREIGN KEY (family_id)
 REFERENCES family (family_id)
 ON DELETE SET NULL ) ---- on delete cascade );



DELETE FROM family   WHERE family_id = 5  --in this time no error


rollback;

Cheers......Halim