Monday, July 20, 2020

sql pofile

Sunday, July 19, 2020

Rename or Move the datafile

1)Make the tablespace offline 

 alter tablespace  offline;


2)MV the all the datafile to new location or rename them 

3)Run the command 

alter database rename file 'C:\ORACLE\DBI\ORADATA\SIT01\test01.dbf' to 'C:\ORACLE\DBI\ORADATA\SIT01\redo\test01.dbf' 

Sunday, May 24, 2020

To change the db into archivelog mode

First check if the DB is runing on pfile or spfile

Below is the steps if DB is in spfile.


SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     10
Current log sequence           12

----- first check in the pfile we do not have any entires of archive dest -- for the first time

SQL>alter system set log_archive_dest_1='LOCATION=C:\oracle\dbi\product\11.2.0\dbhome\database\archive' scope=spfile;

SQL> shutdown  immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount;
ORACLE instance started.

Total System Global Area  744910848 bytes
Fixed Size                  1374696 bytes
Variable Size             276825624 bytes
Database Buffers          461373440 bytes
Redo Buffers                5337088 bytes
Database mounted.

SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

SQL> select name,log_mode from v$database;

NAME      LOG_MODE
--------- ------------
SIT01     ARCHIVELOG

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            C:\oracle\dbi\product\11.2.0\dbhome\database\archive
Oldest online log sequence     10
Next log sequence to archive   12
Current log sequence           12

create the new pfile and we can see entires of archive path.




-----------------------------------------------------------------------------

SHUTDOWN IMMEDIATE;

STARTUP MOUNT;

ALTER DATABASE NOARCHIVELOG;

ALTER DATABASE OPEN;


Monday, October 8, 2018

Important sql's

WF_DEFERRED Queue>>
select decode(wfd.state, 0, '0 = Ready', 1, '1 = Delayed', 2, '2 = Retained', 3, '3 = Exception', to_char(substr(wfd.state,1,12))) State, count(*) count
from applsys.wf_deferred wfd group by wfd.state;

PROMPT <>
select msg_state, count(*) from applsys.aq$wf_notification_out where msg_state in ('WAITING','READY', 'PROCESSED') group by msg_state;

PROMPT <>
select corrid,decode(state,0, '0 = Ready',1, '1 = Delayed',2, '2 = Retained',3, '3 = Exception',to_char(state)) State,count(*) COUNT
from wf_deferred_table_m group by corrid, state;

Stuck thread


select s.inst_id node, s.sid,s.serial# , s.process, p.spid ,s.client_identifier username,
decode(substr(s.program,1,6),'JDBC T','JDBC','frmweb','FORM',s.program) program, substr(s.machine,1,10) machine,
s.module,trunc(s.last_call_et/60/60)||' hr '|| mod(round(s.last_call_et/60),
60)||' Min' lastCal,s.blocking_session blocker ,status
from gv$session s ,
gv$process p
where s.inst_id = p.inst_id and p.addr = s.paddr
and s.action like '%&Resp_name%'
and s.process='&Java_PID'
and s.machine='&machine'
and s.program like 'JDBC Thin Client'
order by 10 desc;

*********************************************************************************************

pid of frmweb

select s.inst_id node, s.sid,s.serial# , s.process, p.spid , s.action, s.machine, s.module, trunc(s.last_call_et/60/60)||' hr '|| mod(round(s.last_call_et/60), 60)||' Min' lastCal,
status from gv$session s ,gv$process p where s.inst_id = p.inst_id and p.addr = s.paddr and s.process = '&PID' order by 4,1;

***********************************************************************************************
prompt JDBC Connection Usage Per JVM Process
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

select machine, process, count(*) from gv$session where program like '%JDBC%' group by machine, process order by 1 asc

prompt
prompt Connection Usage Per Module
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

select count(*), module from gv$session where program like '%JDBC%' group by module order by 1 asc


prompt
prompt Connection Usage Per process and module
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

select count(*), machine, process, module from gv$session where program like '%JDBC%' group by machine, process, module order by 1 asc


prompt
prompt Idle connections for more than 3 hours
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

select count(*),machine, program from gv$session where program like '%JDBC%' and last_call_et > 3600 *3 group by machine, program

prompt
prompt Active connections which are taking more than 10 min to run
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

select * from gv$session where program like '%JDBC%' and last_call_et > 600 and status = 'ACTIVE' order by last_call_et asc

prompt
prompt Statements from JDBC connections taking more than 10 min to run
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

select s.process, s.sid, t.sql_text from gv$session s, gv$sql t where s.sql_address =t.address and s.sql_hash_value =t.hash_value and s.program like '%JDBC%'
and s.last_call_et > 600 and s.status = 'ACTIVE'
/


prompt
prompt Active connections which are taking more than 20 min to run
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

select * from gv$session where program like '%JDBC%' and last_call_et > 1200 and status = 'ACTIVE' order by last_call_et asc
/

prompt
prompt Statements from JDBC connections taking more than 20 min to run
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

select s.process, s.sid, t.sql_text from gv$session s, gv$sql t where s.sql_address =t.address and s.sql_hash_value =t.hash_value
and s.program like '%JDBC%' and s.last_call_et > 1200 and s.status = 'ACTIVE'
/


prompt
prompt Active connections which are taking more than 30 min to run
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

select * from gv$session where program like '%JDBC%' and last_call_et > 1800 and status = 'ACTIVE' order by last_call_et asc
/

prompt
prompt Statements from JDBC connections taking more than 30 min to run
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

select s.process, s.sid, t.sql_text from gv$session s, gv$sql t where s.sql_address =t.address and s.sql_hash_value =t.hash_value
and s.program like '%JDBC%' and s.last_call_et > 1800 and s.status = 'ACTIVE'
/

prompt
prompt Inactive connections which last ran fnd_security_pkg.fnd_encrypted_pwd
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

select s.sql_hash_value, t.sql_text, s.last_call_et from gv$session s , gv$sqltext t where s.username = 'APPLSYSPUB'
and s.sql_hash_value= t.hash_value and t.sql_text like '%fnd_security_pkg.fnd_encrypted_pwd(:1,:2,:3%';

prompt =======================================================

************************************************************************************************************

sess_by_java_pid.sql

select s.inst_id node, s.sid,s.serial# , s.process, p.spid ,s.client_identifier username,
decode(substr(s.program,1,6),'JDBC T','JDBC','frmweb','FORM',s.program) program, substr(s.machine,1,10) machine, s.module,trunc(s.last_call_et/60/60)||' hr '|| mod(round(s.last_call_et/60),
60)||' Min' lastCal,s.blocking_session blocker ,status
from gv$session s ,
gv$process p
where s.inst_id = p.inst_id and p.addr = s.paddr
and s.process='&java_pid'
and s.program like 'JDBC Thin Client'
and s.last_call_et > 1800
order by 10 desc;

*************************************************************************************************

Framework Bundle Code level

SELECT codelevel,
decode((codelevel),
'C.7', '12.2.7 Framework Code Stack',
'C.6', '12.2.6 Framework Code Stack',
'C.5', '12.2.5 Framework Code Stack',
'C.4', '12.2.4 Framework Code Stack',
'B.5', '12.1.3 Framework Code Stack',
'B.4', '11.5.10 Framework Code Stack') stack
FROM AD_TRACKABLE_ENTITIES
WHERE abbreviation='fwk';

Monday, September 17, 2018

dba_editions/patch editions

Actualize the old database editions after online patching to avoid possible performance issues:

During Online patching (ADOP) : An additional column ZD_EDITION_NAME is populated in the seed tables.This happens during th prepare phase.
Online patching doesn't modify run-time seed data by the use of editioned data storage. Creating a (patch) copy of the seed data

Every time we perform online patching , there will an old database edition entry and this will accumulate as and when we do more online patching's.
Oracle suggests that we perform actualize_all after this reaches a count of 25. However it would be time consuming to perform the cleanup after the count has increased.

select count(1) from dba_editions
we also check it ZD_EDITION_NAME in -- FND_PROFILE_OPTION_VALUES

If the number of these grows too large, system performance will start to be affected. When the number of old database editions reaches 25 or more, you should consider dropping all old database editions by running the adop actualize_all phase and then performing a full cleanup.


Steps to remove the editons/full cleanup mode

$ adop phase=prepare
$ adop phase=actualize_all
$ adop phase=finalize finalize_mode=full
$ adop phase=cutover mtrestart=no ?(Manual restart) or adop phase=cutover
$ adop phase=cleanup cleanup_mode=full


Monday, September 10, 2018

Scripts required for 12.2.X custom

1) For new table creations - after creating the table in custom schema execute below script to generate editoning view and synonym for it in APPS schema.

exec AD_ZD_TABLE.UPGRADE('XXCUST','XX_CUST_TBL1');

2) For table alteratuons - after running the DDL run below script to regenerate the editioning view for syncing any table changes.

exec AD_ZD_TABLE.PATCH('XXCUST','XX_CUST_TBL1')

3) Table grants must be done through API to avoid invalids.

exec AD_ZD.GRANT_PRIVS('SELECT','XX_CUST_TBL1','XX_ROLE0')

4) To view objects in all editions..add _ae to the data dictionary views

select * from user_objects_ae;

5) To update seed data tables in Patch edition, execute prepare command.

example:
exec ad_zd_seed.prepare('WF_MESSAGES');

6)exec AD_ZD.compile ('') -- to compile the objects

The prepare will create a edition based storage for the run edition data for which the updates will be made. During cutover, the run time data will be synced using forward/reverse cross edition triggers.

How to Add a Column:

Altering a table – Adding Columns and Indexes

1. Alter table in custom schema the usual way.
alter table cust_table add cust_info varchar2(1) NOT NULL;

Regenerate the editioning view using AD_ZD_TABLE.PATCH
SQL> exec ad_zd_table.patch(table_owner, table_name);

NB: Once the table is altered with the table name, “exec ad_zd_table.patch(‘XXSDS’, ‘cust_table’)” needs to be applied every time

Then:
exec ad_zd_table.upgrade(table_owner, table_name);

RUN EBS Online Patching Database Compliance Checker"(ADZDDBCC.sql)

file location $AD_TOP/sql

for reference check
https://smartdogservices.com/navigating-the-new-waters-of-r12-2-development-customization-part-2/

Monday, August 27, 2018

Enable Database trace for the Apps session

Performance: How to enable Database trace for the Apps session which is already started running
You know how to enable Database trace for Forms & concurrent request, if you know in advance. But if you wish to enable Database trace for the Apps session which already started, then you can use oradebug .

This is required if you wish to do DB tracing when a program suddenly hangs / slow and you do not want to cancel and resubmit.


Steps to enable DB trace dynamically

1) Identify the sid using below sql.

select sid,program,module from v$session
where program like '%f60web%';

2) Identify the SPID

select spid from
v$process
where addr in (
select paddr
from v$session
where sid in (&&));


3) Enable trace using ORADEBUG.

sqlplus /nolog
connect / as sysdba
set echo on
ORADEBUG SETOSPID
ORADEBUG EVENT 10046 TRACE NAME CONTEXT FOREVER, LEVEL 8

4) This enables trace for the running session.
4.1) Trace file will be found in the user_dump_dest.
4.2) tkprof tracefile.trc output.txt explain=apps/ sort=prsela,exeela,fchel

5) If you want to disable , use below command from the same session (step 3)
ORADEBUG EVENT 10046 TRACE NAME CONTEXT off (Rem to turn off; to Switch off the Trace)

Thursday, May 31, 2018

Work flow

Work flow log file location


select fl.meaning,fcp.process_status_code,
decode(fcq.concurrent_queue_name,'WFMLRSVC','maile r container','WFALSNRSVC','listener container',fcq.concurrent_queue_name),
fcp.concurrent_process_id,os_process_id, fcp.logfile_name
from fnd_concurrent_queues fcq, fnd_concurrent_processes fcp , fnd_lookups fl
where fcq.concurrent_queue_id=fcp.concurrent_queue_id and fcp.process_status_code='A'
and fl.lookup_type='CP_PROCESS_STATUS_CODE' and
fl.lookup_code=fcp.process_status_code
and concurrent_queue_name in('WFMLRSVC','WFALSNRSVC')
order by fcp.logfile_name;

or


$APPLCSF/$APPLLOG --FNDCPGSC*.txt

Plan SQL's

SELECT sql_id, plan_hash_value, executions, inst_id FROM gv$sql WHERE sql_id='bhwamkg4y2pxb'; SELECT ...