Drop an Oracle Database using SQLPlus - Drop Database

DBCA is one of the most popular method of dropping an Oracle database. I personally use SQLPlus method. It is simple, fast and removes the files from the storage as well. SQLPlus also doesn't verify the inventory information for the drop.

Please set the environment variables like $ORACLE_SID, $ORACLE_HOME, $PATH. If the database is already up and running, issue a shutdown first. Following are the order of commands:

$ sqlplus / as sysdba
SQL> shutdown immediate;
SQL> startup mount exclusive restrict;
SQL> drop database;
SQL> exit
Please wait for few minutes and you can see the database files are removed.

OPatch Error after copying Oracle Home : Inventory load failed... OPatch cannot load inventory for the given Oracle Home.

In order to save time, I copied Oracle Database Home from one server to another including the inventory. When I tried to do a 'lsinventory' I got the following error:

$opatch lsinventory -invPtrLoc /r01/app/oracle/oradb/oraInventory/oraInst.loc

Oracle Interim Patch Installer version 12.1.0.1.6
Copyright (c) 2015, Oracle Corporation.  All rights reserved.


Oracle Home       : /r01/app/oracle/oradb/12.1.0
Central Inventory : /r01/app/oracle/oradb/oraInventory
   from           : /r01/app/oracle/oradb/oraInventory/oraInst.loc
OPatch version    : 12.1.0.1.6
OUI version       : 12.1.0.2.0
Log file location : /r01/app/oracle/oradb/12.1.0/cfgtoollogs/opatch/opatch2015-06-02_10-31-39AM_1.log

List of Homes on this system:

  Home name= OraDB12Home1, Location= "/u01/app/oracle/oradb/12.1.0"
Inventory load failed... OPatch cannot load inventory for the given Oracle Home.
Possible causes are:
   Oracle Home dir. path does not exist in Central Inventory
   Oracle Home is a symbolic link
   Oracle Home inventory is corrupted
LsInventorySession failed: OracleHomeInventory gets null oracleHomeInfo

OPatch failed with error code 73

Solution:

Go to the Inventory location (in my case /r01/app/oracle/oradb/oraInventory/ContentsXML) and search for inventory.xml. Replace

HOME NAME="OraDB12Home1" LOC="/u01/app/oracle/oradb/12.1.0" TYPE="O" IDX="1"
with
HOME NAME="OraDB12Home1" LOC="/r01/app/oracle/oradb/12.1.0" TYPE="O" IDX="1" 

in the inventory.xml and save it.

Oracle WebCenter Content RCU with 12c database - ORA-01950: no privileges on tablespace

While creating schema for WebCenter Content (11.1.1.8.0) using the RCU ofm_rcu_win_11.1.1.8.0_64_disk1_1of1.zip against a 12c database caused the following error:

JDBC SQLException - ErrorCode: 1950SQLState:42000 Message: ORA-01950: no privileges on tablespace 'WCC_ORAIRM'

Error encountered executing SQL statement  FileName: 'Z:AAAA\Desktop\ofm_rcu_win_11.1.1.8.0_64_disk1_1of1\rcuHome\\rcu\integration\\irm\sql\oracle\create_irm_tables.sql' LineNumber: '64'
SQL Statement: [INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN_TABLE', 0)]
java.sql.SQLSyntaxErrorException: ORA-01950: no privileges on tablespace 'WCC_ORAIRM'

Cause :

This is due to changes in the 12c database compared to 11g: UNLIMITED TABLESPACE is no longer included in RESOURCE role. Quota must be explicitly set by ALTER USER.

Solution:
Go to the RCU location:

Z:AAAA\Desktop\ofm_rcu_win_11.1.1.8.0_64_disk1_1of1\rcuHome\rcu\integration\irm\sql\oracle

alter user &irm_user quota unlimited on &def_tablespace;
or
alter user &&1 quota unlimited on &&3; 

Repeat the following for contentserver11, contentserver11search, capture, ipm, urm.

Oracle System Change Number (SCN) : How to find the current SCN, SCN and Archive Log

Oracle SCN (System Change Number) is a mechanism to maintain data consistency in Oracle database. A stamp that defines a committed version of a database at a point in time. Oracle assigns every committed transaction a unique SCN.

Checkpoint (CKPT) occurs when all modified database buffers in the Oracle SGA are written out to datafiles by the database writer (DBWn) process. It is a data structure that defines an SCN in the redo thread of a database. Checkpoints are recorded in the control file and each datafile header, and are a crucial element of recovery.

How to find current SCN in the database

Method-I
column current_scn format 99999999999999999999;
select current_scn from v$database; 

Method-II
select to_char(dbms_flashback.get_system_change_number) from dual;

Archive Log and SCN:

col first_change# for 999999999999999999
col next_change# for 999999999999999999
select name, thread#, sequence#, status, first_time, next_time 
from v$archived_log 
where &scn between FIRST_CHANGE# and NEXT_CHANGE#;

SCN and Timestamp:
SQL>select scn_to_timestamp(281840233193) as timestamp from dual;

TIMESTAMP
---------------------------------------------------------------------------
04-MAY-15 10.01.49.000000000 AM
SQL>col scn for 99999999999999999999;
SQL>select timestamp_to_scn(to_timestamp('05/04/2015 10:25:01','MM/DD/YYYY HH24:MI:SS')) as scn from dual;

                  SCN
---------------------
         281842111354
SQL>select timestamp_to_scn(to_timestamp('05042015102501','MMDDYYYYHH24MISS')) scn from dual; 
 SCN
---------------------
         281842111354

Other options are to query smon_scn_time and v$log_history. smon_scn_time is owned by SYS and have data worth of 5 days.

11g: Bulk Insert Example

I happen to work recently on a scenario where I had to inset close to 46 Million records . I had to perform a BULK COLLECT (Insert) script so that I dont get ORA-01555: Snapshot too old error.
DECLARE
cursor c1 is
SELECT *
FROM DS.TIME_TEMP_TBLE;

TYPE TYPE_TB1 IS TABLE OF DS.TIME_TARGET_TBLE%ROWTYPE;
TARG_TB1 TYPE_TB1;

l_limit number := 1000000;
BEGIN

OPEN c1;
LOOP
                Fetch c1 BULK COLLECT INTO TARG_TB1 LIMIT l_limit;

                FORALL i IN 1..TARG_TB1.COUNT
                insert into DS.TIME_TARGET_TBLE
                values TARG_TB1(i);
 COMMIT;
        EXIT WHEN c1%ROWCOUNT < l_limit;
END LOOP;
CLOSE c1;
END;
/
COMMIT;
EXIT;

Other different options are to use FOR instead of  FORALL, or use
FORALL i IN TARG_TB1.first..TARG_TB1.last 
From my testing, I felt that using COUNT was faster.

R12.x - ORA-20100: Error: FND_FILE failure. Unable to create file, lxxxxxxx.tmp in the directory, /yyy/zzzz/abc

Concurrent Request Set and Progam results in the following error:
ORA-20100: Error: FND_FILE failure. Unable to create file, lxxxxxx.tmp in the directory, /yyy/zzzz/abc

Oracle Applications produces temporary PL/SQL output files used in concurrent processing. These files are written to a location on the database server node specified by the APPLPTMP environment setting. As the temporary files placed in this directory may contain context sensitive information, it should be a secure directory on the database server node with read and write access for the database server owner. In a multi-node system, the directory defined by APPLPTMP does not need to exist on the application tier servers. In my environment, APPLPTMP= /u03/sqlcom/outbound.

There are many scenarios for this error and I will try to visit most of the cases here.

1. Check the location for APPLPTMP  and confirm that is not 100% full in storage.

2. Set APPLTMP to the first directory in utl_file_dir parameter as FND_FILE writes to the first directory in utl_file_dir.

 SELECT value FROM  v$parameter WHERE name = 'utl_file_dir';

3.  Database Read/Write Check :  If you can write a file using UTL_FILE, which is used by FND_FILE.

set serveroutput on 
DECLARE 
  file_location VARCHAR2(256) := '<first entry on utl_file_dir>'; 
  file_name VARCHAR2(256) := 'utlfile_TEST1.lst'; 
  file_text VARCHAR2(256) := 'THIS IS A TEST'; 
  file_id UTL_FILE.file_type; 
BEGIN 
  file_id := UTL_FILE.fopen(file_Location, file_name, 'W'); 
  UTL_FILE.put_line(file_id, file_text); 
  UTL_FILE.fclose(file_id); 
EXCEPTION 
  WHEN UTL_FILE.INVALID_PATH 
  THEN dbms_output.put_line('Invalid path ' || SQLERRM); 
    WHEN OTHERS 
  THEN dbms_output.put_line('Others '|| SQLCODE || ' ' || SQLERRM); 
END; 
/

If this fails, the issue is on database.

4. Check if you can write a file directly using FND_FILE, which is the package used by the Application. From sqlplus, connected as the apps user, run:

exec FND_FILE.PUT_LINE(FND_FILE.LOG, 'THIS IS A TEST');

If this test works, it would indicate that FND_FILE is working fin.

5. Make sure the file that the concurrent program is trying to create already exists on the APPLPTMP location. Also please verify the permissions on the APPLPTMP directory.

6. If still having problems, your SPFILE may be corrupt or just restart the database. 
 - Shutdown all the Application Services
 - Verify the spfile for the utl_file_dir parameter
 - Restart the database

7. If you decide to change the location of APPLPTMP, Make sure to run autoconfig after changing the APPLPTMP value in the  autoconfig context file.

Reference:
Concurrent Processing - Troubleshooting Concurrent Request ORA-20100 errors in the request logs (Doc ID 261693.1)

R12.2.x Rapid Clone: Application configuration 'perl adcfgclone.pl appsTier' : Oracle Homes are unregistered from the global inventory

Performing Rapid Clone on the application server resulted in an error within few minutes that I triggered 'adcfgclone.pl'. The issue is with Inventory.
$ cd <COMMON_TOP>/clone/bin
$ perl adcfgclone.pl appsTier

Please note that 'fs2' is my RUN Edition in my environment.

Error from adcfgclone.pl:
......
FMW Pre-requisite check log file location : /wms/app/oracle/fs2/EBSapps/comn/clone/FMW/logs/prereqcheck.log

Running: /wms/app/oracle/fs2/EBSapps/comn/clone/FMW/t2pjdk/bin/java -classpath /wms/app/oracle/fs2/EBSapps/comn/clone/prereq/webtier/Scripts/ext/jlib/engine.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/prereq/webtier/oui/jlib/OraPrereq.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/prereq/webtier/oui/jlib/OraPrereqChecks.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/prereq/webtier/oui/jlib/OraInstaller.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/prereq/webtier/oui/jlib/OraInstallerNet.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/prereq/webtier/oui/jlib/srvm.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/prereq/webtier/Scripts/ext/jlib/ojdl.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/prereq/webtier/Scripts/ext/jlib/ojdl2.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/prereq/webtier/Scripts/ext/jlib/ojdl-log4j.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/prereq/webtier/oui/jlib/xmlparserv2.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/prereq/webtier/oui/jlib/share.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/jlib/java oracle.apps.ad.clone.util.FMWOracleHomePreReqCheck -prereqCheckFMW -e /wms/app/oracle/fs2/inst/apps/BERRY_PINK1/appl/admin/BERRY_PINK1.xml -stage /wms/app/oracle/fs2/EBSapps/comn/clone -log /wms/app/oracle/fs2/EBSapps/comn/clone/FMW/logs/prereqcheck.log

Beginning application tier Apply - Fri Jan  9 10:11:06 2015

/wms/app/oracle/fs2/EBSapps/comn/clone/bin/../jre/bin/java -Xmx600M -DCONTEXT_VALIDATED=true -Doracle.installer.oui_loc=/oui -classpath /wms/app/oracle/fs2/EBSapps/comn/clone/jlib/xmlparserv2.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/jlib/ojdbc6.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/jlib/java:/wms/app/oracle/fs2/EBSapps/comn/clone/jlib/oui/OraInstaller.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/jlib/oui/ewt3.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/jlib/oui/share.jar:/wms/app/oracle/fs2/FMW_Home/webtier/../Oracle_EBS-app1/oui/jlib/srvm.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/jlib/ojmisc.jar:/wms/app/oracle/fs2/FMW_Home/wlserver_10.3/server/lib/weblogic.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/jlib/obfuscatepassword.jar  oracle.apps.ad.clone.ApplyAppsTier -e /wms/app/oracle/fs2/inst/apps/BERRY_PINK1/appl/admin/BERRY_PINK1.xml -stage /wms/app/oracle/fs2/EBSapps/comn/clone    -showProgress -nopromptmsg
Log file located at /wms/app/oracle/fs2/inst/apps/BERRY_PINK1/admin/log/clone/ApplyAppsTier_01091011.log
  |      0% completed
ERROR while running Apply...
Fri Jan  9 10:11:08 2015

 ERROR: Failed to execute /wms/app/oracle/fs2/EBSapps/comn/clone/bin/adclone.pl

 Please check logfile.
[applwms@PINK1 bin]$

Logfile (ApplyAppsTier_01091011.log):

#############################################################
Started ApplyAppsTier at Fri Jan 09 10:11:07 CST 2015
Version:
        ApplyAppsTier.java      :       120.11.12020000.6
#############################################################

Below Oracle Homes are already registered in the global inventory:
/wms/app/oracle/fs2/FMW_Home/Oracle_EBS-app1
/wms/app/oracle/fs2/FMW_Home/webtier
/wms/app/oracle/fs2/FMW_Home/oracle_common

Exiting Cloning...

Ensure that the above Oracle Homes are unregistered from the global inventory "/wms/app/oracle/oraInventory/ContentsXML/inventory.xml" and re-run adcfgclone.pl script

Solution:
Go to /wms/app/oracle/fs2/EBSapps/10.1.2/oui/bin (or $ORACLE_HOME/oui/bin) and run the following to unregister the Oracle Homes from the inventory.

$ cd $ORACLE_HOME/oui/bin
$ ./runInstaller -silent -deinstall REMOVE_HOMES={"/wms/app/oracle/fs2/FMW_Home/Oracle_EBS-app1"}
$ ./runInstaller -silent -deinstall REMOVE_HOMES={"/wms/app/oracle/fs2/FMW_Home/oracle_common"}
$ ./runInstaller -silent -deinstall REMOVE_HOMES={"/wms/app/oracle/fs2/FMW_Home/webtier"}

You may have to do the same when you build PATCH Edition (fs1 in my case).

R12.2.x - Application Clone 'perl adcfgclone.pl appsTier' : ..clone/FMW/pasteBinary.sh results in ERROR: Script failed, exit code 255

While performing rapid clone of R12.2.3 environment, I faced an error while running adcfgclone.pl. I performed the below step and it resulted in error :
$ cd <COMMON_TOP>/clone/bin
$ perl adcfgclone.pl appsTier
Please note that 'fs2' is the RUN Edition on my environment.
Error from adcfgclone.pl:
..


Beginning application tier Apply - Fri Jan 16 10:59:52 2015

/wms/app/oracle/fs2/EBSapps/comn/clone/bin/../jre/bin/java -Xmx600M -DCONTEXT_VALIDATED=true -Doracle.installer.oui_loc=/oui -classpath /wms/app/oracle/fs2/EBSapps/comn/clone/jlib/xmlparserv2.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/jlib/ojdbc6.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/jlib/java:/wms/app/oracle/fs2/EBSapps/comn/clone/jlib/oui/OraInstaller.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/jlib/oui/ewt3.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/jlib/oui/share.jar:/wms/app/oracle/fs2/FMW_Home/webtier/../Oracle_EBS-app1/oui/jlib/srvm.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/jlib/ojmisc.jar:/wms/app/oracle/fs2/FMW_Home/wlserver_10.3/server/lib/weblogic.jar:/wms/app/oracle/fs2/EBSapps/comn/clone/jlib/obfuscatepassword.jar  oracle.apps.ad.clone.ApplyAppsTier -e /wms/app/oracle/fs2/inst/apps/BERRY_PINK1/appl/admin/BERRY_PINK1.xml -stage /wms/app/oracle/fs2/EBSapps/comn/clone    -showProgress -nopromptmsg
Log file located at /wms/app/oracle/fs2/inst/apps/BERRY_PINK1/admin/log/clone/ApplyAppsTier_01161059.log
  |      0% completed
ERROR while running Apply...
Fri Jan 16 11:04:01 2015

 ERROR: Failed to execute /wms/app/oracle/fs2/EBSapps/comn/clone/bin/adclone.pl

 Please check logfile.
[applwms@PINK1 bin]$


Log file (ApplyAppsTier_01161059.log): 

[applwms@PINK1 fmwT2PApply]$ cat /wms/app/oracle/fs2/inst/apps/BERRY_PINK1/admin/log/clone/ApplyAppsTier_01161059.log
#############################################################
Started ApplyAppsTier at Fri Jan 16 10:59:53 CST 2015
Version:
        ApplyAppsTier.java      :       120.11.12020000.6
#############################################################

START: Creating the FMW Home from ApplyAppsTier
FMW JDK version in use: 1.7.0_25

START: Creating FMW Home.
Running /wms/app/oracle/fs2/EBSapps/comn/clone/FMW/pasteBinary.sh -javaHome /wms/app/oracle/fs2/EBSapps/comn/util/jdk64 -al /wms/app/oracle/fs2/EBSapps/comn/clone/FMW/FMW_Home.jar -tl /wms/app/oracle/fs2/FMW_Home -invPtrLoc /etc/oraInst.loc -ldl /wms/app/oracle/fs2/inst/apps/BERRY_PINK1/admin/log/clone/fmwT2PApply -silent true -executeSysPrereqs false
Script Executed in 247686 milliseconds, returning status 255
ERROR: Script failed, exit code 255
[applwms@PINK1 fmwT2PApply]$


This doesn't help the error we are getting much unless you check CLONE2015-01-16_10-59-54AM.log and CLONE2015-01-16_10-59-54AM.error files. These files are located on /wms/app/oracle/fs2/inst/apps/BERRY_PINK1/admin/log/clone/fmwT2PApply.

Log file (/wms/app/oracle/fs2/inst/apps/BERRY_PINK1/admin/log/clone/fmwT2PApply/CLONE2015-01-16_10-59-54AM.log): 

INFO : Jan 16, 2015 10:59:55 AM - CLONE-21012   The archive will be restored fully at /wms/app/oracle/fs2/FMW_Home.
INFO : Jan 16, 2015 10:59:55 AM - CLONE-21104   The number of Oracle homes and Middleware homes present in the archive is 3 and 1 respectively.
INFO : Jan 16, 2015 10:59:57 AM - CLONE-21060   No system prerequisites will be executed for the Oracle home /wms/app/oracle/fs2/FMW_Home/oracle_common/ as it is set to false.
INFO : Jan 16, 2015 10:59:57 AM - CLONE-21060   No system prerequisites will be executed for the Oracle home /wms/app/oracle/fs2/FMW_Home/webtier/ as it is set to false.
INFO : Jan 16, 2015 10:59:57 AM - CLONE-21060   No system prerequisites will be executed for the Oracle home /wms/app/oracle/fs2/FMW_Home/Oracle_EBS-app1/ as it is set to false.
INFO : Jan 16, 2015 10:59:57 AM - CLONE-21156   Extracting all the homes from the archive file. Extraction time will vary depending upon the archive size ...
INFO : Jan 16, 2015 10:59:57 AM - CLONE-21157   The size of the all homes are 5.117 GB.
INFO : Jan 16, 2015 11:00:11 AM - CLONE-21126   Operation is 13% complete, in "14" seconds.
INFO : Jan 16, 2015 11:00:38 AM - CLONE-21126   Operation is 20% complete, in "40" seconds.
INFO : Jan 16, 2015 11:01:25 AM - CLONE-21126   Operation is 30% complete, in "87" seconds.
INFO : Jan 16, 2015 11:01:47 AM - CLONE-21126   Operation is 40% complete, in "110" seconds.
INFO : Jan 16, 2015 11:02:07 AM - CLONE-21126   Operation is 50% complete, in "130" seconds.
INFO : Jan 16, 2015 11:02:43 AM - CLONE-21126   Operation is 60% complete, in "165" seconds.
INFO : Jan 16, 2015 11:03:14 AM - CLONE-21126   Operation is 70% complete, in "196" seconds.
INFO : Jan 16, 2015 11:03:51 AM - CLONE-21126   Operation is 80% complete, in "233" seconds.
INFO : Jan 16, 2015 11:04:00 AM - CLONE-21025   Restoring Middleware home at "/wms/app/oracle/fs2/FMW_Home/" from archive "/wms/app/oracle/fs2/EBSapps/comn/clone/FMW/FMW_Home.jar" started ...
INFO : Jan 16, 2015 11:04:01 AM - CLONE-21037   Time taken to restore all cloners from archive was "243" seconds.
INFO : Jan 16, 2015 11:04:01 AM - CLONE-21006   Total time taken by T2P process was 245 seconds.



Error File (/wms/app/oracle/fs2/inst/apps/BERRY_PINK1/admin/log/clone/fmwT2PApply/CLONE2015-01-16_10-59-54AM.error) :

SEVERE : Jan 16, 2015 11:04:00 AM - ERROR - CLONE-20275   Insufficient space to create /tmp/CLONINGCLIENT5418759569442312041.
SEVERE : Jan 16, 2015 11:04:00 AM - CAUSE - CLONE-20275   Minimum required space was at least "1,773" MB, but only "897" MB was available for use.

SEVERE : Jan 16, 2015 11:04:00 AM - ACTION - CLONE-20275   Make sure that the minimum required space is available for use.
SEVERE : Jan 16, 2015 11:04:00 AM - ERROR - CLONE-20233   Restoring Middleware home for sourceid "mwhome1@FMW_Home" has failed.
SEVERE : Jan 16, 2015 11:04:00 AM - CAUSE - CLONE-20233   An internal operation failed.
SEVERE : Jan 16, 2015 11:04:00 AM - ACTION - CLONE-20233   Check the clone log and error file for more details.
SEVERE : Jan 16, 2015 11:04:00 AM - ERROR - CLONE-20237   Restoring the sourceid "mwhome1@FMW_Home" has failed.
SEVERE : Jan 16, 2015 11:04:00 AM - CAUSE - CLONE-20237   An internal operation failed.
SEVERE : Jan 16, 2015 11:04:00 AM - ACTION - CLONE-20237   Check the clone log and error file for more details.
SEVERE : Jan 16, 2015 11:04:01 AM - ERROR - CLONE-20218   Cloning is not successful.
SEVERE : Jan 16, 2015 11:04:01 AM - CAUSE - CLONE-20218   An internal operation failed.
SEVERE : Jan 16, 2015 11:04:01 AM - ACTION - CLONE-20218   Provide the clone log and error file for investigation.

Solution:
/tmp is used by Oracle rapidclone to extract and build FMW Home on the target. Please make sure you have you have at least 2 GB of /tmp space on the target server.