Tuesday, December 4, 2018

How to update GUID for SSO User in Oracle EBS



Extract the GUID for User from Oracle Access Manager (OAM) or OID (ldapsearch)

verify the guid column in the fnd_user table/view with below query :

select user_name,user_id,user_guid from fnd_user where user_name like '%RAJ%';

Now update the guid column in fnd_user with the value extracted above :

update fnd_user  set user_guid='8307ABAC21DAC08BE05016AC32EC512D' where user_name like '%RAJ%';


https://oracletechies-oracleworld.blogspot.com/2018/12/how-to-search-for-ldap-user-oid-user.html


Some Additional queries to check whether the user specified is properly defined in HRMS records (proper email address etc because that's where it pulls all the basic attributes from )

select * from per_all_people_f where email_address like '%RAJ%@xyz.com%';

select * from fnd_user  , per_all_people_f
where per_all_people_f.person_party_id=fnd_user.user_id;

Queries to check Failed and Open status Workflow notifications in Oracle EBS



Select NOTIFICATION_ID, MESSAGE_TYPE, MESSAGE_NAME, STATUS, MAIL_STATUS, FROM_USER, TO_USER ,begin_date,end_date from wf_notifications 
where MAIL_STATUS!='FAILED' and end_date is not null 
order by end_date desc

Select NOTIFICATION_ID, MESSAGE_TYPE, MESSAGE_NAME, STATUS, MAIL_STATUS, FROM_USER, TO_USER ,begin_date,end_date from wf_notifications 
where MAIL_STATUS='FAILED' and end_date is not null 
order by end_date desc



SELECT COUNT(*), message_name,begin_date,status FROM wf_notifications
WHERE STATUS='OPEN'
AND mail_status = 'MAIL'
GROUP BY message_name,begin_date,status ORDER BY begin_date DESC

SELECT * FROM wf_notifications
WHERE STATUS='OPEN'

How to search for ldap user (OID User)



ldapsearch -v -h "Servername01" -p 3060  -D "cn=orcladmin" -w "Passwd" -b "" -s sub "uid=RAJESH@xyz.COM" uid orclguid orclactivestartdate orclactiveenddate orclisenabled


Note: Servername is the OID Servername in above command.

Command to Sync OID Users(LDAP) with Oracle EBS application and Vice versa



syncProfileBootstrap -host servername -port 7005 -D weblogic -profile AD_SYNC_ERP -lp 5




Note: Servername is the OID Servername in above command.

AD_SYNCERP is the OAM profile to sync users between OID and application.

How to modify OID (Ldap) User attributes




ldapmodify -p 3060 -h "servername01" -D cn=orcladmin -w "Passwd" -v -f RAJESH.ldif

Note: Servername is the OID Servername in above command.

Below are the contents of RAJESH.ldf file (RAJESH being modified ro RAJESH1)

cat RAJESH.ldif
dn: cn=RAJESH@XYZ.COM,ou=ebiz,cn=users,dc=eaa,dc=ae
changetype: moddn
newrdn: cn=RAJESH1
deleteoldrdn: 1


Wednesday, November 28, 2018

How to rebuild Work Flow  Queue in Oracle EBS



Work Flow  Queue Rebuild Activity
=========================
1)Stop the queue as below :
rem stop queue
exec dbms_aqadm.stop_queue(queue_name => 'APPLSYS.WF_NOTIFICATION_OUT');

2)Drop the queue as below :
rem drop queue
exec dbms_aqadm.drop_queue(queue_name => 'APPLSYS.WF_NOTIFICATION_OUT');

3)Drop the queue table as below :
rem drop queue table
exec dbms_aqadm.drop_queue_table( queue_table=> 'APPLSYS.WF_NOTIFICATION_OUT',force=>true);

4)Create the queue table  as below :
rem create queue table
begin
dbms_aqadm.create_queue_table
(
queue_table => 'WF_NOTIFICATION_OUT',
queue_payload_type => 'SYS.AQ$_JMS_TEXT_MESSAGE',
sort_list => 'PRIORITY,ENQ_TIME',
multiple_consumers => TRUE,
comment => 'Workflow JMS Topic',
compatible => '8.1'
);
exception
when others then
raise_application_error(-20000, 'Oracle Error Mkr2= '||to_char(sqlcode)||' - '||sqlerrm);
end;
/

5)Create the queue as below :

rem create queue
begin
dbms_aqadm.create_queue
(
queue_name => 'WF_NOTIFICATION_OUT',
queue_table => 'WF_NOTIFICATION_OUT',
max_retries => 5,
retry_delay => 3600,
retention_time => 86400,
comment => 'Workflow JMS Topics'
);
exception
when others then
raise_application_error(-20000, 'Oracle Error Mkr4= '||to_char(sqlcode)||' - '||sqlerrm);
end;
/

6)Start the queue as below :
rem start queue
begin
dbms_aqadm.start_queue(queue_name => 'WF_NOTIFICATION_OUT');
exception
when others then
raise_application_error(-20000, 'Oracle Error Mkr5= '||to_char(sqlcode)||' - '||sqlerrm);
end;
/
rem start exception queue
begin
dbms_aqadm.start_queue(queue_name => 'AQ$_WF_NOTIFICATION_OUT_E',enqueue => FALSE);
exception
when others then
raise_application_error(-20000, 'Oracle Error Mkr9= '
||to_char(sqlcode)||' - '||sqlerrm);
end;
/

7)Add subscriber as below :

rem add subscriber
declare
lagent sys.aq$_agent;
subscriber_exist exception;
pragma EXCEPTION_INIT(subscriber_exist, -24034);
begin
lagent := sys.aq$_agent('WF_NOTIFICATION_OUT',null,0);
dbms_aqadm.add_subscriber(queue_name =>'APPLSYS.WF_NOTIFICATION_OUT',subscriber=>lagent, rule=>'1=1');
exception
when subscriber_exist then
dbms_aqadm.alter_subscriber(queue_name =>'APPLSYS.WF_NOTIFICATION_OUT',subscriber=>lagent,rule=>'1=1');
null; -- ignore if we already added this subscriber.
end;
/
commit;

Monday, November 26, 2018

Query to check or list out for Purge programs in Oracle EBS




SELECT REQUEST_ID, SUBSTR(USER_CONCURRENT_PROGRAM_NAME,1,80) "PROGRAM NAME", REQUEST_DATE
FROM APPS.FND_CONC_REQ_SUMMARY_V
WHERE USER_CONCURRENT_PROGRAM_NAME LIKE '%urge%' OR USER_CONCURRENT_PROGRAM_NAME LIKE '%elete%'
ORDER BY REQUEST_DATE,"PROGRAM NAME";



SELECT SUBSTR(B.APPLICATION_SHORT_NAME,1,11) "APPLICATION",
       SUBSTR(A.USER_CONCURRENT_PROGRAM_NAME,1,50) "CONCURRENT PROGRAM NAME",
       SUBSTR(A.CONCURRENT_PROGRAM_NAME,1,35) "SHORT NAME"
FROM APPS.FND_CONCURRENT_PROGRAMS_VL A, APPS.FND_APPLICATION_VL B
  WHERE A.APPLICATION_ID=B.APPLICATION_ID
  AND A.ENABLED_FLAG='Y'
  AND (A.USER_CONCURRENT_PROGRAM_NAME LIKE '%urge%'
  OR A.USER_CONCURRENT_PROGRAM_NAME LIKE '%elete%')
ORDER BY B.APPLICATION_SHORT_NAME;

Sunday, August 5, 2018

Oracle EBS R12.2 Cloning Steps



DB Tier

Cloning Steps on the Target node after  running adpreclone.pl on source node (db Tier & AppsTier)

adpreclone.pl dbTier (on Db node)

adpreclone.pl appsTier (on Apps Node)

scp -r erpdbtuat@server01:/erpbintuat/erptuat/ /u01

or

scp -r erpdbtuat@DBserver01:/erpbintuat/erptuat/prod_apps.tar.gz  /u01

(Note : rename the base directory from erpuat to erptest i.e to instance name you are copying)

cd $ORACLE_HOME/appsutil/clone/bin

perl adcfgclone.pl dbTechStack

sqlplus "/as sysdba"

startup nomount pfile='$ORACLE_HOME/dbs/initERPCLONE.ora'

copy the the rman backups to the destination filesystem (if its in accessible shared location then no need to copy)

rman auxiliary /
run {
allocate AUXILIARY channel c0 type disk;
allocate AUXILIARY channel c1 type disk;
allocate AUXILIARY channel c2 type disk;
allocate AUXILIARY channel c3 type disk;
allocate AUXILIARY channel c4 type disk;
allocate AUXILIARY channel c5 type disk;
allocate AUXILIARY channel c6 type disk;
allocate AUXILIARY channel c7 type disk;
duplicate target database to "ERPCLONE" BACKUP LOCATION '/stage/backup/' NOFILENAMECHECK;
RELEASE CHANNEL c0;
RELEASE CHANNEL c1;
RELEASE CHANNEL c2;
RELEASE CHANNEL c3;
RELEASE CHANNEL c4;
RELEASE CHANNEL c5;
RELEASE CHANNEL c6;
RELEASE CHANNEL c7;
}

Take care of post db activities like password resets ,re-pointing db links and purging tables can be done now else these can also be done after Apps Tier Cloning Completes

Run Autoconfig $ORACLE_HOME/appsutil/scripts/instance_name/adautocfg.sh


=======================================================================
Apps Tier

adpreclone.pl appsTier

 (remove the Apps Tier Dir Structure under  /u01)

1) Copy the Apps Tar file from PROD to CLONE
rm  /u01/applprod/prod_apps_tar/prod_apps.tar.gz
scp applprod@appsserver01: /u01/backup/prod_apps.tar.gz  /u01/

scp -r applprod@appsserver01:/erpbintuat/erptuat/ /u01

2) Delete the Apps Directories

cd /u01/ERPCLONE/fs1

(Remove the below directories that will be replaced by the source copy)

rm -rf EBSapps FMW_Home_* inst_*
mv FMW_Home FMW_Home_orig
mv inst inst_orig

3) Untar the Apps tar file
cd /u01/ERPCLONE/fs1

 tar -zxvf /prod_apps.tar.gz .
(do not miss the dot at the end )

4) Run adcfgclone

cd /u01/CLONE/backup

cp ERPCLONE_server01.xml_bkup ERPCLONE_server01.xml

Here you have two ways/options of cloning

1) perl adcfgclone.pl appsTier 

 (this will only create/clone the run filesystem in case you dont want to maintain patch fs in test environment)

2)adcfgclone.pl  appsTier dualfs

(this will create both Run fs and Patch fs )

perl '/u01/ERPCLONE/fs1/EBSapps/comn/clone/bin/adcfgclone.pl' appsTier /u01/backup/ERPCLONE_server01.xml

Enter the APPS user password:
Enter the WebLogic AdminServer password:

5) After adcfgclone , enable SSL

Modify the Oracle HTTP Server wallet

cd  /u01/ERPCLONE/fs1/FMW_Home/webtier/instances/EBS_web_ERPCLONE_OHS1/config/OHS/EBS_web_ERPCLONE/keystores/default/

mv cwallet.sso cwallet.sso_bkp
cp/u01/ERPCLONE/fs_ne/inst/ERPCLONE_server01/certs/Apache/cwallet.sso .

6) Update the Context File and Configuration Files

7)Change the permission of “.apachectl” file using sudo privilege on both the Run and Patch File Systems as the root user.

sudo chown root $FMW_HOME/webtier/ohs/bin/.apachectl
sudo chmod 6750 $FMW_HOME/webtier/ohs/bin/.apachectl


8) Take backup of ssl.conf
/u01/ERPCLONE/fs1/FMW_Home/webtier/instances/EBS_web_ERPCLONE_OHS1/config/OHS/EBS_web_ERPCLONE/ssl.conf and update the below parameter values

•         Start the node manager and admin server on the run file system after sourcing the Run environment.
•         Execute below command on all application tier nodes to propagate the changes made in ssl/httpd configuration to the context file variables:
perl $AD_TOP/bin/adSyncContext.pl contextfile=$CONTEXT_FILE
Enter the APPS user password:
Enter the WebLogic AdminServer password:

•  Stop the node manager and admin server

Edit run file system Context file and update the values to reflect as below

Variable Expected Value
s_url_protocol https
s_local_url_protocol https
s_webentryurlprotocol https
s_active_webport 443
s_webssl_port 443
s_https_listen_parameter 443
s_login_page https://server01.com:443/OA_HTML/AppsLogin

s_external_url https://server01.com:443

s_webentryhost   server01
s_webentrydomain   .com


Run AutoConfig using the adautocfg.sh script in the application tier $ADMIN_SCRIPTS_HOME directory


====================================================
Known Issues

1)  During EBS Cloning Instance is already registered in inventory so de-register it as below :

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

cd /ptchapps/ERPCLONE/fs1/EBSapps/10.1.2/oui/bin

./runInstaller -silent -deinstall REMOVE_HOMES={"/u01/ERPCLONE/fs1/FMW_Home/Oracle_EBS-app1"}

./runInstaller -silent -deinstall REMOVE_HOMES={"/u01/ERPCLONE/fs1/FMW_Home/webtier"}

./runInstaller -silent -deinstall REMOVE_HOMES={"/u01/ERPCLONE/fs1/FMW_Home/oracle_common"}

./runInstaller -silent -deinstall REMOVE_HOMES={"/u01/ERPCLONE/fs1/FMW_Home/Oracle_OAMWebGate1"}

then Re-run adcfgclone.pl

2) EBS Login Page is not loading


perl $FND_TOP/patch/115/bin/ojspCompile.pl --compile --flush -p 2
logfile set: /u01/ERPCLONE/fs1/inst/apps/ERPCLONE_server01/logs/appl/rgf/ojsp/ojspc_error.log
starting...(compiling all)
using 10i internal ojsp ver: 10.3.6.0
synchronizing dependency file:
  loading deplist...7831
  enumerating jsps...7836
  updating dependency...5153
  parsing jsp...5153
  writing deplist...7831
initializing compilation:
  eliminating children...5963 (-1873)
translating and compiling:
  translating jsps...5963/5963 in 17m17s
  compiling jsps...5963/5963 in 15m10s
Finished!

Tuesday, July 24, 2018

Commands to find and Remove old logs from Oracle RAC environment (reclaim filesystem space)



cd $ORACLE_BASE  or $GRID_BASE

find . -name "evmlog.*" -mtime +15 -exec rm -f  {} \;

find . -name "+ASM*.trc*" -mtime +15 -exec ls -ltr  {} \;
find . -name "evmlog.*" -mtime +15 -exec rm  -f {} \;

find . -name "*.xml" -mtime +10 -exec ls -ltr  {} \;

find . -name "ora_*.trc*" -mtime +15 -exec rm -f {} \;
find . -name "+ASM_ora*.aud*" -mtime +15 -exec rm -f{} \;


Command to list files by their size :

ls -l | sort -k 5 -rn

Changing Apps Password in Oracle EBS R 12.1.3

1. Shut down application services with adstpall.sh script 

   sh adstpall.sh apps/hirbzlcc

   sh adopmnctl.sh stop

2. FNDCPASS apps/hirbzlcc 0 Y system/wnEV6wTCza SYSTEM APPLSYS ftfgrufz

3. run autoconfig on dbtier than run it on  appstier with new password

(run autoconfig.sh on each apps node & db node)

4. Start up all application services with  adstrtal.sh 

sh adstrtal.sh apps/ujbehpiw 

sh adopmnctl.sh start

Oracle EBS 12.1.3 Instance Cloning


Cloning Steps on the Target node after  running adpreclone.pl on source node (db Tier & AppsTier)

i.e

adpreclone.pl dbTier

adpreclone.pl appsTier


scp -r erpdbtuat@server01:/erpbintuat/erptuat/ /u01  

or

scp -r erpdbtuat@DBserver01:/erpbintuat/erptuat/prod_apps.tar.gz  /u01

(Note : rename the base directory from erpuat to erptest i.e to instance name you are copying)

cd /u0l/ERPTEST/db/11.2.0.4/appsutil/clone/bin

perl adcfgclone.pl dbTechStack

sqlplus "/as sysdba"

startup nomount pfile='$ORACLE_HOME/dbs/initERPTEST.ora'

copy the the rman backups to the destination filesystem (if its in accessible shared location then no need to copy)

rman auxiliary /
run {
allocate AUXILIARY channel c0 type disk;
allocate AUXILIARY channel c1 type disk;
allocate AUXILIARY channel c2 type disk;
allocate AUXILIARY channel c3 type disk;
allocate AUXILIARY channel c4 type disk;
allocate AUXILIARY channel c5 type disk;
allocate AUXILIARY channel c6 type disk;
allocate AUXILIARY channel c7 type disk;
duplicate target database to "ERPTEST" BACKUP LOCATION '/stage/backup/' NOFILENAMECHECK;
RELEASE CHANNEL c0;
RELEASE CHANNEL c1;
RELEASE CHANNEL c2;
RELEASE CHANNEL c3;
RELEASE CHANNEL c4;
RELEASE CHANNEL c5;
RELEASE CHANNEL c6;
RELEASE CHANNEL c7;
}

Take care of post db activities like password resets ,re-pointing db links and purging tables can be done now else these can also be done after Apps Tier Cloning Completes

Run Autoconfig $ORACLE_HOME/appsutil/scripts/instance_name/adautocfg.sh
==================================================================
Apps Tier

scp -r erpappstuat@appsserver01:/erpbintuat/erptuat/ /u01

 or 

untar tar -zxvf  prod_apps.tar.gz     (remove the Apps Tier Dir Structure under  /u01)

cd /u02/ERPTEST/apps/apps_st/comn/clone/bin

perl adcfgclone.pl appsTier

(Note: Rename  Instance specific Directory mv erptuat_server01 ERPTEST_server02)

cd  $IAS_ORACLE_HOME/certs/Apache/cwallet.sso .

mv cwallet.sso cwallet.sso_bkp

Perform post Clone activities like updating the workflow notificaon mailer address to Test/clone environment as per your requirement (you could leave it blank as well)

============================================
Trouble Shooting Login Page issues (When Login page goes Blank after cloning)

rm -rf $ORA_CONFIG_HOME/10.1.3/j2ee/oacore/persistence/*
rm -rf $ORA_CONFIG_HOME/10.1.3/j2ee/oafm/persistence/*
rm -rf $ORA_CONFIG_HOME/10.1.3/j2ee/forms/persistence/*
perl $FND_TOP/patch/115/bin/ojspCompile.pl --compile --flush -p 2

Wednesday, July 4, 2018

Migrating & Upgrading Oracle 11G to 12c Database


Migrating & Upgrading Oracle 11.2.0.4 to 12c Database

Copy the the Oracle Home from "tar -cvf oh.tar $ORACLE_HOME "  to new server

 export ORACLE_HOME=/u01/data/db/11.2.0.4
 export ORACLE_BASE=/u01/data/
 export PATH=$ORACLE_HOME/bin:$PATH
 export ORACLE_SID=PROD


./runInstaller -silent -clone ORACLE_BASE="/u01/data/" ORACLE_HOME="/u01/data/db/11.2.0.4" ORACLE_HOME_NAME="OraHome1"

 ./relink all

writing relink log to: /u01/data/db/11.2.0.4/install/relink.log


---./runInstaller -silent -attachHome -invPtrLoc /etc/oraInst.loc \ ORACLE_HOME="/u01/data/db/11.2.0.4" ORACLE_HOME_NAME="OraHome1"

orapwd file=$ORACLE_HOME/dbs/orapwPROD password=Welcome1 force=y

Take Rman backup of Source Database

rman target /


run

{
CONFIGURE CONTROLFILE AUTOBACKUP ON;
allocate channel c1 type disk format '/stage/Backup/%U';
allocate channel c2 type disk format '/stage/Backup/%U';
allocate channel c3 type disk format '/stage/Backup/%U';
allocate channel c4 type disk format '/stage/Backup/%U';
sql 'alter system archive log current';
BACKUP AS COMPRESSED BACKUPSET DATABASE;
sql 'alter system archive log current';
BACKUP AS COMPRESSED BACKUPSET ARCHIVELOG ALL;
backup CURRENT CONTROLFILE format '/stage/Backup/cntrl_%s_%p_%t';
RELEASE CHANNEL c1;
RELEASE CHANNEL c2;
RELEASE CHANNEL c3;
RELEASE CHANNEL c4;
}


Clone DB from Source Backup

Bring up the instance in nomount

sqlplus "/as sysdba"
startup nomount pfile='/u01/data/db/11.2.0.4/dbs/initPROD.ora'
(Edit the Control file .archive log paths accordingly to the the new 12c Home / Mount points)

Connect to Auxiliary instance to clone the DB from RMAN backup

rman auxiliary sys/Welcome1


run {
allocate AUXILIARY channel c0 type disk;
allocate AUXILIARY channel c1 type disk;
allocate AUXILIARY channel c2 type disk;
allocate AUXILIARY channel c3 type disk;
allocate AUXILIARY channel c4 type disk;
allocate AUXILIARY channel c5 type disk;
allocate AUXILIARY channel c6 type disk;
allocate AUXILIARY channel c7 type disk;
duplicate target database to "PROD" BACKUP LOCATION '/stage/Backup/' NOFILENAMECHECK;
RELEASE CHANNEL c0;
RELEASE CHANNEL c1;
RELEASE CHANNEL c2;
RELEASE CHANNEL c3;
RELEASE CHANNEL c4;
RELEASE CHANNEL c5;
RELEASE CHANNEL c6;
RELEASE CHANNEL c7;
}


Install the 12c Binaries under /u01/oracle12c/  by invoking ./runInstaller  from Install directory

Set the ORACLE_HOME and PATH variables pointing to newly installed ORACLE 12C Binaries
export ORACLE_HOME=/u01/oracle12c/dbhome/product/12.1.0
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=PROD

Got to cd $ORACLE_HOME/bin  and invoke  ./dbua




Tuesday, July 3, 2018

How to Sync Oracle Standby Database (DataGuard) when the archive gap is very large

SQL> select DATABASE_ROLE from v$database;

DATABASE_ROLE
----------------
PHYSICAL STANDBY

SQL> select current_scn from v$database;

    CURRENT_SCN
-----------------------
10180880784901

QL> alter database recover managed standby database cancel;

Database altered.



rman target /
run
{
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/stage/prod/Backup_30May/%F';
allocate channel c1 type disk format '/stage/prod/Backup/%U';
allocate channel c2 type disk format '/stage/prod/Backup/%U';
allocate channel c3 type disk format '/stage/prod/Backup/%U';
allocate channel c4 type disk format '/stage/prod/Backup/%U';
allocate channel c5 type disk format '/stage/prod/Backup/%U';
allocate channel c6 type disk format '/stage/prod/Backup/%U';
allocate channel c7 type disk format '/stage/prod/Backup/%U';
backup incremental from scn 10180880784901 database;
}


alter database create standby controlfile as '/stage/prod/Backup/for_standby.ctl'

SQL> startup nomount

replace the previous controlfile with this new one created at primary , and Bring the database to MOUNT state

alter database mount standby database;

rman target /

RMAN> catalog start with '/stage/prod/Backup/';


recover database;

Again Check the SCN’s in primary and standby to make sure that both are in SYNc:

SQL> select current_scn from v$database;

================================================================================================================


Option B


rman target sys/passwd@PROD auxiliary /
run
{
ALLOCATE AUXILIARY CHANNEL CH01 TYPE disk format '/stage/prod/Backup/%U';
ALLOCATE AUXILIARY CHANNEL CH02 TYPE disk format '/stage/prod/Backup/%U';
DUPLICATE TARGET DATABASE FOR STANDBY NOFILENAMECHECK;
}



SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;



ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;



Query to check which session is using TEMPORARY Tablepace




select  su.username , ses.sid ,ses.serial# , su.tablespace , ceil((su.blocks * dt.block_size) / 1048576) MB
from v$sort_usage su ,dba_tablespaces dt , v$session ses where   su.tablespace = dt.tablespace_name and su.session_addr = ses.saddr order by MB desc

Saturday, June 2, 2018


Online rename and relocation of an active data file

Unlike in the previous releases, a data file migration or renaming in Oracle database 12c R1 no longer requires a number of steps i.e. putting the tablespace in READ ONLY mode, followed by data file offline action. In 12c R1, a data file can be renamed or moved online simply using the ALTER DATABASE MOVE DATAFILE SQL statement. While the data file is being transferred, the end user can perform queries, DML and DDL tasks. Additionally, data files can be migrated between storages e.g. from non-ASM to ASM and vice versa.
C:\APP\ORA12C\ORADATA\ORCL\USERS01.DBF
Alter database move datafile ‘C:\APP\ORA12C\ORADATA\ORCL\USERS01.DBF’
 To ‘C:\APP\ORA12C\ORADATA\Testdir\USERS_01.DBF’ ;


Alter database move datafile 'C:\APP\ORA12C\ORADATA\Testdir\USERS_01.DBF'
 To 'C:\APP\ORA12C\ORADATA\newdir\USERS_01.DBF' reuse;
(The old datafile gets cleaned up automatically)
(Old datafile is retained while creating new datafile)
You can monitor the progress while a data file being moved by querying the v$session_longops dynamic view. Additionally, you can also refer the alert.log of the database where Oracle writes the details about action being taken place.


Invisible columns

In Oracle 11g R1, Oracle introduced a couple of good enhancements in the form of invisible indexes and virtual columns. Taking the legacy forward, invisible column concepts has been introduced in Oracle 12c R1. I still remember, in the previous releases, to hide important data –columns from being displayed in the generic queries– we used to create a view hiding the required information or apply some sort of security conditions.In 12c R1, you can now have an invisible column in a table. When a column is defined as invisible, the column won’t appear in generic queries, unless the column is explicitly referred to in the SQL statement or condition, or DESCRIBED in the table definition. It is pretty easy to add or modify a column to be invisible and vice versa:
Invisible Column

Multiple indexes on the same column

Pre Oracle 12c, you can’t create multiple indexes either on the same column or set of columns in any form. For example, if you have an index on column {a} or columns {a,b}, you can’t create another index on the same column or set of columns in the same order. In 12c, you can have multiple indexes on the same column or set of columns as long as the index type is different. However, only one type of index is usable/visible at a given time. In order to test the invisible indexes, you need to set the optimizer_use_use_invisible_indexes=true.
DDL logging
There was no direction option available to log the DDL action in the previous releases. In 12cR1, you can now log the DDL action into xml and log files. This will be very useful to know when the drop or create command was executed and by who. The ENABLE_DDL_LOGGING initiation parameter must be configured in order to turn on this feature. The parameter can be set at the database or session levels. When this parameter is enabled, all DDL commands are logged in an xml and a log file under the $ORACLE_BASE/diag/rdbms/DBNAME/log|ddl location. An xml file contains information, such as DDL command, IP address, timestamp etc. This helps to identify when a user or table dropped or when a DDL statement is triggered.
To enable DDL logging

How to execute SQL statement in RMAN

In 12c, you can now execute any SQL and PL/SQL commands in RMAN without the need of a SQL prefix: you can execute any SQL and PLS/SQL commands directly from RMAN. How you can execute SQL statements in RMAN

Restricting PGA size

Pre Oracle 12c R1, there was no option to limit and control the PGA size. Although, you set a certain size toPGA_AGGREGATE_TARGET initialization parameter, Oracle could increase/reduce the size of the PGA dynamically based on the workload and requirements. In 12c, you can set a hard limit on PGA by enabling the automatic PGA management, which requires PGA_AGGREGATE_LIMIT parameter settings. Therefore, you can now set the hard limit on PGA by setting the new parameter to avoid excessive PGA usage
Important notes:
When the current PGA limits exceeds, Oracle will automatically terminates/abort the session/process that holds the most untenable PGA memory

Adding multiple new partitions

Before Oracle 12c R1, it was only possible to add one new partition at a time to an existing partitioned table. To add more than one new partition, you had to execute an individual ALTER TABLE ADD PARTITION statement to every new partition. Oracle 12c provides the flexibility to add multiple new partitions using a single ALTER TABLE ADD PARTITION command. The following example explains how to add multiple new partitions to an existing partitioned table:
 In the same way, you can add multiple new partitions to a list and system partitioned table, provided that theMAXVALUE partition doesn’t exist.

How to drop and truncate multiple partitions/sub-partitions

As part of data maintenance, you typically either use drop or truncate partition maintenance task on a partitioned table.  Pre 12c R1, it was only possible to drop or truncate one partition at a time on an existing partitioned table.  With Oracle 12c, multiple partitions or sub-partitions can be dropped or merged using a single ALTER TABLE table_name {DROP|TRUNCATE} PARTITIONS command.
The following example explains how to drop or truncate multiple partitions on an existing partitioned table:
SQL> ALTER TABLE emp_part DROP PARTITIONS p4,p5;
SQL> ALTER TABLE emp_part TRUNCATE PARTITONS p4,p5;

Gathering  statistics concurrently on multiple tables

In previous Oracle database editions, whenever you execute a DBMS_STATS procedure to gather table, index, schema or database level statistics, Oracle used to collect stats one table at a time. If the table is big enough, then increasing the parallelism was recommended. With 12c R1, you can now collect stats on multiple tables, partitions and sub partitions concurrently.  Before you start using it, you must set the following at the database level to enable the feature:



 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Transport view as table

This is another improvement in the data pumps. With the new VIEWS_AS_TABLES option, you can unload the view data into a table. The following example describes how to unload views data into a table during export.

expdp directory=expdp_dir dumpfile=emp_part.dmp logfile=emp_part.log views_as_tables=system.emp_part1

RMAN

 

 

Start container AND pluggable databases .


But then we find that the Pluggable Databases (PDBs) are still in "MOUNTED" state, so we will need to open them before we can login.


From CDB$ROOT we can manage any PDB.

we can move down to a PDB container to stop and start them individually.

To open ALL PDBS

SQL> alter pluggable database all open;
SQL> select name, open_mode from v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PDB1                           READ WRITE
PDB2                           READ WRITE
PDB3                           READ WRITE

Startup of PDBs can be automated using a startup trigger.


SQL> create or replace trigger Sys.After_Startup
                          after startup on database
begin
   execute immediate 'alter pluggable database all open';
end;
/
User creations
Common users belongs to CBD’s as well as current and future PDB’s. It means it can performed operation in Container or Pluggable according to Privileges assigned. For more information about common user.
Local users is purely database that belongs to only single PDB. This user may have administrative privileges but this only belongs to that PDB. For more information about local user.
// Consider following example in which i am trying to create common user in container root.





RMAN Features

 

Complete recovery of CDB, PDB and root
You should have SYSBACKUP or SYSDBA privilege to restore any of the databases.
Restoring Container Database (CDB) is similar to non-container database.
You can restore the whole CDB using below script:

RMAN> RUN {
     STARTUP MOUNT;
     RESTORE DATABASE;
     RECOVER DATABASE;
     ALTER DATABASE OPEN;
}
Note that restoring CDB database will restore all the pluggable databases.
You can restore only ROOT Database using below script:

RMAN> RUN {
     STARTUP MOUNT;
     RESTORE DATABASE ROOT;
     RECOVER DATABASE ROOT;
     ALTER DATABASE OPEN;
}

Oracle 12c Database Features

Online rename and relocation of an active data file
Unlike in the previous releases, a data file migration or renaming in Oracle database 12c R1 no longer requires a number of steps i.e. putting the tablespace in READ ONLY mode, followed by data file offline action. In 12c R1, a data file can be renamed or moved online simply using the ALTER DATABASE MOVE DATAFILE SQL statement. While the data file is being transferred, the end user can perform queries, DML and DDL tasks. Additionally, data files can be migrated between storages e.g. from non-ASM to ASM and vice versa.

C:\APP\ORA12C\ORADATA\ORCL\USERS01.DBF
Alter database move datafile ‘C:\APP\ORA12C\ORADATA\ORCL\USERS01.DBF’
To ‘C:\APP\ORA12C\ORADATA\Testdir\USERS_01.DBF’ ;




Alter database move datafile 'C:\APP\ORA12C\ORADATA\Testdir\USERS_01.DBF'
To 'C:\APP\ORA12C\ORADATA\newdir\USERS_01.DBF' reuse;


(The old datafile gets cleaned up automatically)

(Old datafile is retained while creating new datafile)
You can monitor the progress while a data file being moved by querying the v$session_longops dynamic view. Additionally, you can also refer the alert.log of the database where Oracle writes the details about action being taken place.


Invisible columns
In Oracle 11g R1, Oracle introduced a couple of good enhancements in the form of invisible indexes and virtual columns. Taking the legacy forward, invisible column concepts has been introduced in Oracle 12c R1. I still remember, in the previous releases, to hide important data –columns from being displayed in the generic queries– we used to create a view hiding the required information or apply some sort of security conditions.In 12c R1, you can now have an invisible column in a table. When a column is defined as invisible, the column won’t appear in generic queries, unless the column is explicitly referred to in the SQL statement or condition, or DESCRIBED in the table definition. It is pretty easy to add or modify a column to be invisible and vice versa:
Invisible Column


Multiple indexes on the same column
Pre Oracle 12c, you can’t create multiple indexes either on the same column or set of columns in any form. For example, if you have an index on column {a} or columns {a,b}, you can’t create another index on the same column or set of columns in the same order. In 12c, you can have multiple indexes on the same column or set of columns as long as the index type is different. However, only one type of index is usable/visible at a given time. In order to test the invisible indexes, you need to set the optimizer_use_use_invisible_indexes=true.

DDL logging
There was no direction option available to log the DDL action in the previous releases. In 12cR1, you can now log the DDL action into xml and log files. This will be very useful to know when the drop or create command was executed and by who. The ENABLE_DDL_LOGGING initiation parameter must be configured in order to turn on this feature. The parameter can be set at the database or session levels. When this parameter is enabled, all DDL commands are logged in an xml and a log file under the $ORACLE_BASE/diag/rdbms/DBNAME/log|ddl location. An xml file contains information, such as DDL command, IP address, timestamp etc. This helps to identify when a user or table dropped or when a DDL statement is triggered.
To enable DDL logging


How to execute SQL statement in RMAN
In 12c, you can now execute any SQL and PL/SQL commands in RMAN without the need of a SQL prefix: you can execute any SQL and PLS/SQL commands directly from RMAN. How you can execute SQL statements in RMAN
Restricting PGA size
Pre Oracle 12c R1, there was no option to limit and control the PGA size. Although, you set a certain size toPGA_AGGREGATE_TARGET initialization parameter, Oracle could increase/reduce the size of the PGA dynamically based on the workload and requirements. In 12c, you can set a hard limit on PGA by enabling the automatic PGA management, which requires PGA_AGGREGATE_LIMIT parameter settings. Therefore, you can now set the hard limit on PGA by setting the new parameter to avoid excessive PGA usage

Important notes:
When the current PGA limits exceeds, Oracle will automatically terminates/abort the session/process that holds the most untenable PGA memory
Adding multiple new partitions
Before Oracle 12c R1, it was only possible to add one new partition at a time to an existing partitioned table. To add more than one new partition, you had to execute an individual ALTER TABLE ADD PARTITION statement to every new partition. Oracle 12c provides the flexibility to add multiple new partitions using a single ALTER TABLE ADD PARTITION command. The following example explains how to add multiple new partitions to an existing partitioned table:
In the same way, you can add multiple new partitions to a list and system partitioned table, provided that theMAXVALUE partition doesn’t exist.


How to drop and truncate multiple partitions/sub-partitions
As part of data maintenance, you typically either use drop or truncate partition maintenance task on a partitioned table. Pre 12c R1, it was only possible to drop or truncate one partition at a time on an existing partitioned table. With Oracle 12c, multiple partitions or sub-partitions can be dropped or merged using a single ALTER TABLE table_name {DROP|TRUNCATE} PARTITIONS command.
The following example explains how to drop or truncate multiple partitions on an existing partitioned table:
SQL> ALTER TABLE emp_part DROP PARTITIONS p4,p5;
SQL> ALTER TABLE emp_part TRUNCATE PARTITONS p4,p5;

Gathering statistics concurrently on multiple tables
In previous Oracle database editions, whenever you execute a DBMS_STATS procedure to gather table, index, schema or database level statistics, Oracle used to collect stats one table at a time. If the table is big enough, then increasing the parallelism was recommended. With 12c R1, you can now collect stats on multiple tables, partitions and sub partitions concurrently. Before you start using it, you must set the following at the database level to enable the feature:





















Transport view as table
This is another improvement in the data pumps. With the new VIEWS_AS_TABLES option, you can unload the view data into a table. The following example describes how to unload views data into a table during export.


expdp directory=expdp_dir dumpfile=emp_part.dmp logfile=emp_part.log views_as_tables=system.emp_part1

RMAN



Start container AND pluggable databases .


But then we find that the Pluggable Databases (PDBs) are still in "MOUNTED" state, so we will need to open them before we can login.

From CDB$ROOT we can manage any PDB.
we can move down to a PDB container to stop and start them individually.

To open ALL PDBS

SQL> alter pluggable database all open;
SQL> select name, open_mode from v$pdbs;

NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PDB1 READ WRITE
PDB2 READ WRITE
PDB3 READ WRITE

Startup of PDBs can be automated using a startup trigger.

SQL> create or replace trigger Sys.After_Startup
after startup on database
begin
execute immediate 'alter pluggable database all open';
end;
/
User creations
Common users belongs to CBD’s as well as current and future PDB’s. It means it can performed operation in Container or Pluggable according to Privileges assigned. For more information about common user.
Local users is purely database that belongs to only single PDB. This user may have administrative privileges but this only belongs to that PDB. For more information about local user.
// Consider following example in which i am trying to create common user in container root.






RMAN Features





Complete recovery of CDB, PDB and root
You should have SYSBACKUP or SYSDBA privilege to restore any of the databases.
Restoring Container Database (CDB) is similar to non-container database.
You can restore the whole CDB using below script:

RMAN> RUN {
STARTUP MOUNT;
RESTORE DATABASE;
RECOVER DATABASE;
ALTER DATABASE OPEN;
}
Note that restoring CDB database will restore all the pluggable databases.
You can restore only ROOT Database using below script:

RMAN> RUN {
STARTUP MOUNT;
RESTORE DATABASE ROOT;
RECOVER DATABASE ROOT;
ALTER DATABASE OPEN;
}