Scripts
For Oracle DBAs for make their life easier
Tablespace Management
col "Tablespace" for a22col "Used MB" for 99,999,999col "Free MB" for 99,999,999col "Total MB" for 99,999,999
select df.tablespace_name "Tablespace",totalusedspace "Used MB",(df.totalspace - tu.totalusedspace) "Free MB",df.totalspace "Total MB",round(100 * ( (df.totalspace - tu.totalusedspace)/ df.totalspace))"Pct. Free"from(select tablespace_name,round(sum(bytes) / 1048576) TotalSpacefrom dba_data_filesgroup by tablespace_name) df,(select round(sum(bytes)/(1024*1024)) totalusedspace, tablespace_namefrom dba_segmentsgroup by tablespace_name) tuwhere df.tablespace_name = tu.tablespace_name ; col FILE_NAME for a70 set lines 200selectTABLESPACE_NAME,FILE_NAME,bytes/1024/1024/1024,maxbytes/1024/1024/1024,STATUS,AUTOEXTENSIBLEfrom dba_data_files where TABLESPACE_NAME like '%&1%' order by file_name;
select file_id,file_name,bytes/1024/1024,autoextensible,maxbytes/1024/1024 from dba_data_files where tablespace_name='POX';
alter tablespace POX add datafile '/mount/oracle/proddata/pox32.dbf' size 200m autoextend on maxsize 7500m;
select file_name from dba_data_files where file_name like '%a_txn_data95%';select file_name from dba_data_files where file_name like '%axk%'; alter tablespace APPS_TS_TX_DATA add datafile '/datamount/ndhans/oradata/APPS_TS_TX_DATA149.dbf' size 2G;
Movie or renam datafile :alter database move datafile 32 to '/datamount/ndhans/oradata/APPS_TS_TX_DATA142.dbf'
/ud1020/PROD/oradata/a_txn_data94.dbf alter tablespace APPS_TS_TX_DATA add datafile '/udata/PROD/oradata/a_txn_data95.dbf' resize 10G;
alter tablespace APPS_TS_TX_DATA add datafile '/udata/test/oradata/a_txn_data63.dbf' size 10G; Undo usage by session:
set lines 140ITCHafele3900!col name heading 'UNDO|Name' form a12col module heading 'Module' form a18 trunccol username heading 'User' form a10 wrapcol sql_hash_value heading 'Hash Value' form 9999999999col totsize heading 'Undo Bytes Used' form 999,999,999,999col log_io heading 'Redo Log I/O' form 999,999,999col phy_io heading 'Physical I/O' form 999,999,999col used_ublk heading 'Undo Blks' form 9,999,999col spid heading 'Svr|PID' form 999999col sid heading 'SID' form 99999col serial# heading 'Serial#' form 9999999 select r.name, p.spid,s.sid,s.serial#,s.username,s.module,s.sql_hash_value,t.used_ublk,used_ublk*8192 totsize,t.log_io,t.phy_iofrom v$transaction t, v$session s,v$process p, sys.v_$rollname rwhere t.ses_ADDR = s.saddrAND p.addr = s.paddrand t.xidusn = r.usnand used_ublk*8192 > 10000000order by r.name,totsize desc/ To chechk autoextension on or not; col FILE_NAME for a50;set lines 200;select TABLESPACE_NAME,FILE_NAME,bytes/1024/1024,maxbytes/1024/1024,STATUS,AUTOEXTENSIBLE from dba_data_files where TABLESPACE_NAME like '%&1%' order by file_name;
UNDO: SELECT d.tablespace_name, round(((NVL(f.bytes,0) + (a.maxbytes - a.bytes))/1048576+ u.exp_space),2)as max_free_mb, round(((a.bytes - (NVL(f.bytes,0)+ (1024*1024*u.exp_space)))*100/a.maxbytes),2)used_pct FROM sys.dba_tablespaces d, (select tablespace_name, sum(bytes) bytes,sum(greatest(maxbytes,bytes)) maxbytes from sys.dba_data_files group by tablespace_name) a,(select tablespace_name, sum(bytes) bytes from sys.dba_free_space group by tablespace_name) f ,(select tablespace_name , sum(blocks)*8/(1024) exp_space from dba_undo_extents where status NOT IN ('ACTIVE','UNEXPIRED') group by tablespace_name) uWHERE d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = f.tablespace_name(+)AND d.tablespace_name=u.tablespace_name AND d.contents = 'UNDO' AND u.tablespace_name = (select UPPER(value)from v$parameter where name = 'undo_tablespace');
Since the undo retention is no guarantee, unexpired segments can also be used for future transactions.So, we can safely ignore this alert.Please find below spool for more reference.
select tablespace_name,retention from dba_tablespaces where tablespace_name='&UNDOTBS1';
V$TRANSACTION linked with V$SESSION will show current used undo blocks for ongoing transactions. This query may help:
SELECT a.sid, a.username, b.used_urec, b.used_ublkFROM v$session a, v$transaction bWHERE a.saddr = b.ses_addrORDER BY b.used_ublk DESC
To show ACTIVE/EXPIRED/UNEXPIRED Extents of Undo Tablespace
select tablespace_name, status,count(extent_id) "Extent Count",sum(blocks) "Total Blocks", sum(blocks)*8/(1024*1024) total_spacefrom dba_undo_extentsgroup by tablespace_name, status; select tablespace_name, status,count(extent_id) "Extent Count",sum(blocks) "Total Blocks", sum(blocks)*8/(1024*1024) total_spacefrom dba_undo_extentsgroup by tablespace_name, status;
SELECT a.tablespace_name, ROUND((a.tablespace_size * b.block_size) / 1048576, 1) AS "Tablespace size (MB)", ROUND((a.used_space * b.block_size) / 1048576, 1) AS "Used space (MB)" FROM dba_tablespace_usage_metrics a JOIN dba_tablespaces b ON a.tablespace_name = b.tablespace_name Where a.TABLESPACE_NAME like '%UNDO%'
select tablespace_name, status,count(extent_id) "Extent Count",sum(blocks) "Total Blocks", sum(blocks)*8/(1024*1024) total_spacefrom dba_undo_extentsgroup by tablespace_name, status;
set linesize 152 col tablespace_name for a20col status for a10
select tablespace_name,status,count(extent_id) "Extent Count",sum(blocks) "Total Blocks",sum(bytes)/(1024*1024*1024) spaceInGBfrom dba_undo_extentswhere tablespace_name in ('&undotbsp')group by tablespace_name,status;
To show UndoRetention Value
Show parameter undo_retention;
Undo retention in hours
col "Retention" for a30col name for a30col value for a50select name "Retention",value/60/60 "Hours" from v$parameter where name like '%undo_retention%';
SELECT a.sid, b.name, a.valueFROM v$sesstat a, v$statname bWHERE a.statistic# = b.statistic#AND a.statistic# = 176ORDER BY a.value DESC
Undo Space Utilization by each Sessions
set lines 200col sid for 99999col username for a10col name for a15select s.sid,s.serial#,username,s.machine,t.used_ublk ,t.used_urec,rn.name,(t.used_ublk *8)/1024/1024 SizeGBfrom v$transaction t,v$session s,v$rollstat rs, v$rollname rnwhere t.addr=s.taddr and rs.usn=rn.usn and rs.usn=t.xidusn and rs.xacts>0;
To check for Active Transactions
set head onselect usn,extents,round(rssize/1048576)rssize,hwmsize,xacts,waits,optsize/1048576 optsize,shrinks,wrapsfrom v$rollstat where xacts>0order by rssize;
SELECT a.sid, b.name, a.valueFROM v$sesstat a, v$statname bWHERE a.statistic# = b.statistic#AND a.statistic# = 176ORDER BY a.value DESC;
set lines 200col sid for 99999col username for a10col name for a15select s.sid,s.serial#,username,s.machine,t.used_ublk ,t.used_urec,rn.name,(t.used_ublk *8)/1024/1024 SizeGBfrom v$transaction t,v$session s,v$rollstat rs, v$rollname rnwhere t.addr=s.taddr and rs.usn=rn.usn and rs.usn=t.xidusn and rs.xacts>0;
Concurrent Requests
set echo off pages 100 lines 202column REQUEST heading 'Request' format a9column PHASE heading 'Phase' format A8column STATUS heading 'Status' format A8column PROGRAM heading 'Program Name' format A40column SHORT heading 'Short Name' format A15column REQUESTOR heading 'Requestor' format A15column START_TIME heading 'Start Time' format A15column RUN_TIME justify left heading 'Time(e)' format 999999.9column OSPID heading 'OSPID' format a5column OS_PIDa heading 'OSPIDA' format a6column SID heading 'SID' format 99999column serial# heading 'Serial#' format 99999select substr(fcrv.request_id,1,9)REQUEST,decode(fcrv.phase_code,'P','Pending','R','Running','I','Inactive','Completed')PHASE,decode(fcrv.status_code,'A','Waiting','B','Resuming','C','Normal','F','Scheduled','G','Warning','H','On Hold','I','Normal','M','No Manager','Q','Standby','R','Normal','S','Suspended','T','Terminating','U','Disabled','W','Paused','X','Terminated','Z','Waiting',fcrv.status_code)STATUS,substr(fcrv.program,1,40)PROGRAM,substr(fcrv.PROGRAM_SHORT_NAME,1,15)SHORT,substr(fcrv.requestor,1,15)REQUESTOR,-- to_char(fcrv.actual_start_date,'MM/DD/RR HH24:MI')START_TIME,round(((sysdate - fcrv.actual_start_date)*1440),1)RUN_TIME,substr(fcr.oracle_process_id,1,7)OSPID,s.sid,s.serial#--substr(fcr.os_process_id,1,7)OS_PIDafrom apps.fnd_conc_req_summary_v fcrv,apps.fnd_concurrent_requests fcr,v$session s,v$process pwhere fcrv.phase_code = 'R'and fcrv.request_id = fcr.request_idand s.paddr = p.addrand fcr.oracle_process_id = p.spidand fcrv.concurrent_program_id not in ('40112','40113','36887')--and trunc(fcrv.actual_start_date) like trunc(sysdate)order by PHASE, STATUS, REQUEST desc;
TO check concurrent program status from backend
select REQUEST_ID,LAST_UPDATE_DATE,REQUEST_DATE,REQUESTED_BY,PHASE_CODE,STATUS_CODE from apps.fnd_concurrent_requests where REQUEST_ID='&reqid';
select REQUEST_ID,LAST_UPDATE_DATE,REQUEST_DATE,REQUESTED_BY,PHASE_CODE,STATUS_CODE from apps.fnd_concurrent_requests where REQUEST_ID LIKE '1228202%';
update apps.fnd_concurrent_requests set phase_code='C',status_code='X' where request_id='142070381';
To find run alone requests
select request_id,status_code,phase_code from fnd_concurrent_requestswhere CONCURRENT_PROGRAM_ID in (SELECT CONCURRENT_PROGRAM_IDFROM FND_CONCURRENT_PROGRAMS_VLWHERE RUN_ALONE_FLAG='Y' );
Last call ETA
select sid,serial#,status,sql_id,last_call_et from v$session where sid='4201';
Previous_Runs:
******************************************************************
SELECT a.request_id,b.user_concurrent_program_name,to_char(a.actual_start_date,'DD-MON-RR HH24:MI:SS'),to_char(a.actual_completion_date,'DD-MON-RR HH24:MI:SS'),decode(a.phase_code,'R','Running','P','Inactive','C','Completed', a.phase_code),decode(a.status_code,'E','Error', 'C','Normal', 'X','Terminated', 'Q','On Hold', 'D','Cancelled', 'G','Warning', 'R','Normal', 'W', 'Paused', a.status_code),a.ARGUMENT_TEXT FROM apps.fnd_concurrent_programs_vl b,apps.fnd_concurrent_requests aWHERE a.concurrent_program_id = b.concurrent_program_id and b.user_concurrent_program_name like '%&CONCURRENT_PROGRAM%' order by 3;
To find long running requests sid,pid:
******************************************************************SELECT a.request_id, d.sid, d.serial# ,d.osuser,d.process , c.SPID ,d.inst_idFROM apps.fnd_concurrent_requests a,apps.fnd_concurrent_processes b,gv$process c,gv$session dWHERE a.controlling_manager = b.concurrent_process_idAND c.pid = b.oracle_process_idAND b.session_id=d.audsidAND a.request_id =&req_idAND a.phase_code = 'R';
SELECT a.request_id, d.sid, d.serial# ,d.osuser,d.process , c.SPID ,d.inst_idFROM apps.fnd_concurrent_requests a,apps.fnd_concurrent_processes b,gv$process c,gv$session dWHERE a.controlling_manager = b.concurrent_process_idAND c.pid = b.oracle_process_idAND b.session_id=&d.audsidAND a.phase_code = 'R';
******************************************************************
set lines 205col ARGUMENT_TEXT for a47col USER_CONCURRENT_PROGRAM_NAME for a47SELECT a.request_id,b.user_concurrent_program_name,to_char(a.actual_start_date,'DD-MON-RR HH24:MI:SS'),to_char(a.actual_completion_date,'DD-MON-RR HH24:MI:SS'),decode(a.phase_code,'R','Running','P','Inactive','C','Completed', a.phase_code),decode(a.status_code,'E','Error', 'C','Normal', 'X','Terminated', 'Q','On Hold', 'D','Cancelled', 'G','Warning', 'R','Normal', 'W', 'Paused', a.status_code),a.ARGUMENT_TEXT FROM apps.fnd_concurrent_programs_vl b,apps.fnd_concurrent_requests aWHERE a.concurrent_program_id = b.concurrent_program_id and b.user_concurrent_program_name like 'XXAS HBK Planning Report (German)';
select c.request_id, r.responsibility_namefrom fnd_responsibility_vl r, fnd_concurrent_requests cwhere c.request_id = 106765679and c.responsibility_application_id = r.application_idand c.responsibility_id = r.responsibility_id
select REQUEST_ID,LAST_UPDATE_DATE,REQUEST_DATE,REQUESTED_BY,PHASE_CODE,STATUS_CODE from apps.fnd_concurrent_requests where REQUEST_ID IN ('125115793','125115794','125115795','125115789','125115790','125115792','125115791');
Requests completion date details
SELECT request_id, TO_CHAR( request_date, ‘DD-MON-YYYY HH24:MI:SS’ )request_date, TO_CHAR( requested_start_date,’DD-MON-YYYY HH24:MI:SS’ )requested_start_date, TO_CHAR( actual_start_date, ‘DD-MON-YYYY HH24:MI:SS’ )actual_start_date, TO_CHAR( actual_completion_date, ‘DD-MON-YYYY HH24:MI:SS’ )actual_completion_date, TO_CHAR( sysdate, ‘DD-MON-YYYY HH24:MI:SS’ )current_date, ROUND( ( NVL( actual_completion_date, sysdate ) – actual_start_date ) * 24, 2 ) durationFROM fnd_concurrent_requestsWHERE request_id = TO_NUMBER(‘&p_request_id’);
Request id from sid
SELECT a.request_id, a.PHASE_CODE, a.STATUS_CODE,d.sid as Oracle_SID,d.serial#,d.osuser,d.process,c.SPID as OS_Process_IDFROM apps.fnd_concurrent_requests a,apps.fnd_concurrent_processes b,gv$process c,gv$session dWHERE a.controlling_manager = b.concurrent_process_idAND c.pid = b.oracle_process_idAND b.session_id=d.audsid AND a.PHASE_CODE=’R’ AND a.STATUS_CODE=’R’AND d.sid = &SID;
How to Determine Which Manager Ran a Specific Concurrent Request
col USER_CONCURRENT_QUEUE_NAME for a100select b.USER_CONCURRENT_QUEUE_NAME from fnd_concurrent_processes a,fnd_concurrent_queues_vl b, fnd_concurrent_requests cwhere a.CONCURRENT_QUEUE_ID = b.CONCURRENT_QUEUE_IDand a.CONCURRENT_PROCESS_ID = c.controlling_managerand c.request_id = ‘&conc_reqid’;
Concurrent request status for a given sid
col MODULE for a20col OSUSER for a10col USERNAME for a10set num 10col MACHINE for a20set lines 200col SCHEMANAME for a10select s.INST_ID,s.sid,s.serial#,p.spid os_pid,s.status, s.osuser,s.username, s.MACHINE,s.MODULE, s.SCHEMANAME,s.action from gv$session s, gv$process p WHERE s.paddr = p.addr and s.sid = ‘&oracle_sid’;
Find out request id from Oracle_Process Id
select REQUEST_ID,ORACLE_PROCESS_ID,OS_PROCESS_Id from apps.fnd_concurrent_requests where ORACLE_PROCESS_ID=’&a’;
To find concurrent program name,phase code,status code for a given request id
SELECT request_id, user_concurrent_program_name, DECODE(phase_code,’C’,’Completed’,phase_code) phase_code, DECODE(status_code,’D’, ‘Cancelled’ ,‘E’, ‘Error’ , ‘G’, ‘Warning’, ‘H’,’On Hold’ , ‘T’, ‘Terminating’, ‘M’, ‘No Manager’ , ‘X’, ‘Terminated’, ‘C’, ‘Normal’, status_code) status_code, to_char(actual_start_date,’dd-mon-yy:hh24:mi:ss’) Start_Date, to_char(actual_completion_date,’dd-mon-yy:hh24:mi:ss’), completion_text FROM apps.fnd_conc_req_summary_v WHERE request_id = ‘&req_id’ ORDER BY 6 DESC;
To find the sql query for a given concurrent request sid
select sid,sql_text from gv$session ses, gv$sqlarea sql where ses.sql_hash_value = sql.hash_value(+) and ses.sql_address = sql.address(+) and ses.sid=’&oracle_sid’/
To find child requests for Parent request id
set lines 200col USER_CONCURRENT_PROGRAM_NAME for a40col PHASE_CODE for a10col STATUS_CODE for a10col COMPLETION_TEXT for a20SELECT sum.request_id,req.PARENT_REQUEST_ID,sum.user_concurrent_program_name, DECODE(sum.phase_code,’C’,’Completed’,sum.phase_code) phase_code, DECODE(sum.status_code,’D’, ‘Cancelled’ ,‘E’, ‘Error’ , ‘G’, ‘Warning’, ‘H’,’On Hold’ , ‘T’, ‘Terminating’, ‘M’, ‘No Manager’ , ‘X’, ‘Terminated’, ‘C’, ‘Normal’, sum.status_code) status_code, sum.actual_start_date, sum.actual_completion_date, sum.completion_text FROM apps.fnd_conc_req_summary_v sum, apps.fnd_concurrent_requests req where req.request_id=sum.request_id and req.PARENT_REQUEST_ID = ‘&parent_concurrent_request_id’;set col os_process_id for 99select HAS_SUB_REQUEST, is_SUB_REQUEST, parent_request_id, ORACLE_PROCESS_ID, ORACLE_SESSION_ID, OS_PROCESS_ID from fnd_concurrent_requests where request_id= ‘&Req_ID’ ;
To terminate the all concurrent requests using by Module wise
select ‘ALTER SYSTEM KILL SESSION ”’||sid||’,’||serial#||”’ immediate;’ from gv$session where MODULE like ‘GLPREV’;
History of concurrent requests which are error out
SELECT a.request_id “Req Id”,a.phase_code,a.status_code, actual_start_date, actual_completion_date,c.concurrent_program_name || ‘: ‘ || ctl.user_concurrent_program_name “program”FROM APPLSYS.fnd_Concurrent_requests a,APPLSYS.fnd_concurrent_processes b,applsys.fnd_concurrent_queues q,APPLSYS.fnd_concurrent_programs c,APPLSYS.fnd_concurrent_programs_tl ctlWHERE a.controlling_manager = b.concurrent_process_idAND a.concurrent_program_id = c.concurrent_program_idAND a.program_application_id = c.application_idAND a.status_code = ‘E’AND a.phase_code = ‘C’AND actual_start_date > sysdate – 2AND b.queue_application_id = q.application_idAND b.concurrent_queue_id = q.concurrent_queue_idAND ctl.concurrent_program_id = c.concurrent_program_idAND ctl.LANGUAGE = ‘US’ORDER BY 5 DESC;
Find out Concurrent Program which enable with trace
col User_Program_Name for a40col Last_Updated_By for a30col DESCRIPTION for a30SELECT A.CONCURRENT_PROGRAM_NAME “Program_Name”,SUBSTR(A.USER_CONCURRENT_PROGRAM_NAME,1,40) “User_Program_Name”,SUBSTR(B.USER_NAME,1,15) “Last_Updated_By”,SUBSTR(B.DESCRIPTION,1,25) DESCRIPTIONFROM APPS.FND_CONCURRENT_PROGRAMS_VL A, APPLSYS.FND_USER BWHERE A.ENABLE_TRACE=’Y’AND A.LAST_UPDATED_BY=B.USER_ID;
Concurrent Program count under QUEUE
col “program name” format a55;col “name” format a17;col “queue name” format a15col “statuscode” format a3select user_CONCURRENT_PROGRAM_NAME “PROGRAM NAME”,concurrent_queue_name “QUEUE NAME”, priority,decode(phase_code,’P’,’Pending’) “PHASE”,decode(status_code,’A’,’Waiting’,’B’,’Resuming’,’C’,’Normal’,’D’,’Cancelled’,’E’,’Error’,’F’,‘Scheduled’,’G’,’Warning’,’H’,’On Hold’,’I’,’Normal’,’M’,’No Manager’,’Q’,’Standby’,’R’,’Normal’,’S’,‘Suspended’,’T’,’Terminating’,’U’,’Disabled’,’W’,’Paused’,’X’,’Terminated’,’Z’,’Waiting’) “NAME”, status_code,count(*) fromfnd_concurrent_worker_requestswhere phase_code=’P’ and hold_flag!=’Y’and requested_start_date<=sysdateand concurrent_queue_name<> ‘FNDCRM’and concurrent_queue_name<> ‘GEMSPS’group byuser_CONCURRENT_PROGRAM_NAME,concurrent_queue_name,priority,phase_code,status_codeorder by count(*) desc/
Lists the Manager Names with the No. of Requests in Pending/Running
col “USER_CONCURRENT_QUEUE_NAME” format a40;SELECT a.USER_CONCURRENT_QUEUE_NAME,a.MAX_PROCESSES,sum(decode(b.PHASE_CODE,’P’,decode(b.STATUS_CODE,’Q’,1,0),0)) Pending_Standby,sum(decode(b.PHASE_CODE,’P’,decode(b.STATUS_CODE,’I’,1,0),0)) Pending_Normal,sum(decode(b.PHASE_CODE,’R’,decode(b.STATUS_CODE,’R’,1,0),0)) Running_NormalFROM FND_CONCURRENT_QUEUES_VL a, FND_CONCURRENT_WORKER_REQUESTS bwhere a.concurrent_queue_id = b.concurrent_queue_idAND b.Requested_Start_Date<=SYSDATEGROUP BY a.USER_CONCURRENT_QUEUE_NAME,a.MAX_PROCESSES;Concurrent QUEUE Details ###set echo offset linesize 130set serveroutput on size 50000set feed offset veri offDECLARErunning_count NUMBER := 0;pending_count NUMBER := 0;crm_pend_count NUMBER := 0;–get the list of all conc managers and max worker and running workersCURSOR conc_que ISSELECT concurrent_queue_id,concurrent_queue_name,user_concurrent_queue_name,max_processes,running_processesFROM apps.fnd_concurrent_queues_vlWHERE enabled_flag=’Y’ andconcurrent_queue_name not like ‘XDP%’ andconcurrent_queue_name not like ‘IEU%’ andconcurrent_queue_name not in (‘ARTAXMGR’,’PASMGR’) ;BEGINDBMS_OUTPUT.PUT_LINE(‘====================================================================================================’);DBMS_OUTPUT.PUT_LINE(‘QueueID’||’ ‘||’Queue ‘||‘Concurrent Queue Name ‘||’ ‘||’MAX ‘||’ ‘||’RUN ‘||’ ‘||‘Running ‘||’ ‘||’Pending ‘||’ ‘||’In CRM’);DBMS_OUTPUT.PUT_LINE(‘====================================================================================================’);FOR i IN conc_queLOOP–for each manager get the number of pending and running requests in each queueSELECT /*+ RULE */ nvl(sum(decode(phase_code, ‘R’, 1, 0)), 0),nvl(sum(decode(phase_code, ‘P’, 1, 0)), 0)INTO running_count, pending_countFROM fnd_concurrent_worker_requestsWHERErequested_start_date <= sysdateand concurrent_queue_id = i.concurrent_queue_idAND hold_flag != ‘Y’;–for each manager get the list of requests pending due to conflicts in each managerSELECT /*+ RULE */ count(1)INTO crm_pend_countFROM apps.fnd_concurrent_worker_requests aWHERE concurrent_queue_id = 4AND hold_flag != ‘Y’AND requested_start_date <= sysdateAND exists (SELECT ‘x’FROM apps.fnd_concurrent_worker_requests bWHERE a.request_id=b.request_idand concurrent_queue_id = i.concurrent_queue_idAND hold_flag != ‘Y’AND requested_start_date <= sysdate);–print the output by joining the outputs of manager counts,DBMS_OUTPUT.PUT_LINE(rpad(i.concurrent_queue_id,8,’_’)||rpad(i.concurrent_queue_name,15, ‘ ‘)||rpad(i.user_concurrent_queue_name,40,’ ‘)||rpad(i.max_processes,6,’ ‘)||rpad(i.running_processes,6,’ ‘)||rpad(running_count,10,’ ‘)||rpad(pending_count,10,’ ‘)||rpad(crm_pend_count,10,’ ‘));–DBMS_OUTPUT.PUT_LINE(‘—————————————————————————————————-‘);END LOOP;DBMS_OUTPUT.PUT_LINE(‘====================================================================================================’);END;/set verify onset echo on
Clone Pre Backups
Database Pre Backup Script
vi db_pre_clone.sh
cd ~mkdir clone_`date +"%d%b%Y"`export PWD_DIR=$HOME/clone_`date +"%d%b%Y"`cd $PWD_DIRcp $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora $PWD_DIR
cp $ORACLE_HOME/dbs/init$ORACLE_SID.ora $PWD_DIR
cp $ORACLE_HOME/oraInst.loc $PWD_DIR
cp $ORACLE_HOME/*.env $PWD_DIR
cp $ORACLE_HOME/appsutil/*.xml $PWD_DIR
cp -R $ORACLE_HOME/network/admin/* $PWD_DIR
sqlplus -s "/as sysdba" <<EOF > $PWD_DIR/pc1.logspool Precloneinfo.log
alter database backup controlfile to trace as '$PWD_DIR/ctrl_$ORACLE_SID.sql';
create pfile='$PWD_DIR/initpfile.ora' from spfile;
PromptPrompt === dblinks ===Prompt ========================================Prompt
begin dbms_metadata.set_transform_param (dbms_metadata.session_transform, 'SQLTERMINATOR', true); dbms_metadata.set_transform_param (dbms_metadata.session_transform, 'PRETTY', true);end;/
set lines 200set pages 20000col DB_LINK for a50col USERNAME for a20col HOST for a50select * from dba_db_links;
SELECT 'create '||DECODE(U.NAME,'PUBLIC','public ')||'database link '||CHR(10) ||DECODE(U.NAME,'PUBLIC',Null, U.NAME||'.')|| L.NAME||chr(10) ||'connect to ' || L.USERID || ' identified by ' ||L.PASSWORD||' using ''' || L.host || '''' ||chr(10)||';' TEXT FROM sys.link$ L, sys.user$ U WHERE L.OWNER# = U.USER#;
PromptPrompt === dba_directories ===Prompt ========================================Prompt
set lines 300col DIRECTORY_NAME for a40col DIRECTORY_PATH for a90select * from dba_directories;
select 'create or replace directory '||DIRECTORY_NAME||' as '''||DIRECTORY_PATH||''';' from dba_directories;
archive log list
show parameter backgr
PromptPrompt === temp_files ===Prompt ========================================Prompt
set lines 200col FILE_NAME for a80;select file_name,tablespace_name,bytes/1024/1024,status from dba_temp_files;
PromptPrompt === data_files ===Prompt ========================================Prompt
select file_name,tablespace_name,bytes/1024/1024,status from dba_data_files;
PromptPrompt === control_files ===Prompt ========================================Promptselect name from v\$controlfile;
PromptPrompt === redolog_files ===Prompt ========================================Promptcol MEMBER for a60set lines 200select * from v\$logfile;
select * from v\$log;
PromptPrompt === all directories of db CRD files ===Prompt ========================================Promptselect substr(name,1,instr(name,'/',-1)) from v\$datafileunionselect substr(name,1,instr(name,'/',-1)) from v\$tempfileunionselect substr(member,1,instr(member,'/',-1)) from v\$logfileunionselect substr(name,1,instr(name,'/',-1)) from v\$controlfile;
PromptPrompt === status of CRD files ===Prompt ========================================Promptselect distinct status from v\$datafileunionselect distinct status from v\$tempfileunionselect distinct status from v\$logfileunionselect distinct status from v\$controlfile;
PromptPrompt === size and count of datafiles on each mount ===Prompt ========================================Promptset lines 300col DATAFILES_DIR for a50select substr(name, 1, instr(name, '/', -1)) datafiles_DIR, count(1) datafiles_count,sum(bytes/1024/1024/1024) size_in_GB from v\$datafile group by rollup (substr(name, 1, instr(name, '/', -1))) order by 1;
PromptPrompt === size and count of tempfiles on each mount ===Prompt ========================================Promptset lines 300col TEMPFILES_DIR for a50select substr(name, 1, instr(name, '/', -1)) tempfiles_DIR, count(1) tempfiles_count,sum(bytes/1024/1024/1024) size_in_GB from v\$tempfile group by rollup (substr(name, 1, instr(name, '/', -1))) order by 1;
PromptPrompt ===all file locations of db ===Prompt ========================================Promptselect distinct substr(name, 1, instr(name, '/', -1)) || ' -- DATAfiles' from v\$datafile unionselect distinct substr(name, 1, instr(name, '/', -1)) || ' -- TEMPfiles' from v\$tempfile unionselect distinct substr(member, 1, instr(member, '/', -1)) || ' -- LOGfiles' from v\$logfile unionselect distinct substr(name, 1, instr(name, '/', -1)) || ' -- Controlfiles' from v\$controlfile;
select node_name from apps.fnd_nodes;
archive log list
select distinct status from v\$backup;show parameter remotearchive log listshow parameter spfileshow parameter db_nameshow parameter db_unique_nameshow parameter nameshow parameter createshow parameter convertshow parameter sgashow parameter multishow parameter utlshow parameter diagsho parameter backshow parameter audit
show parameter backgr
show parameter utl
show parameter service
show parameter listen
Prompt *****Public synonym backup before import***********set long 900000select dbms_metadata.get_ddl(object_type=>'SYNONYM',name=>synonym_name,schema=>'PUBLIC') from all_synonymswhere owner='PUBLIC' and table_owner not in ('SYS')PromptPrompt === tablespace creation script ===Prompt ========================================Prompt
set long 900000select dbms_metadata.get_ddl('TABLESPACE',tb.tablespace_name) from dba_tablespaces tb;
PromptPrompt === user creation script ===Prompt ========================================Prompt
set long 9999999select dbms_metadata.get_ddl('USER', username) || '/' usercreate from dba_users;
PromptPrompt === username -- password script ===Prompt ========================================Prompt
select 'alter user '|| name||' identified by values '|| ''''|| password||''''||';' from SYS.USER$ WHERE password is not null;
PromptPrompt === username -- its Default tablespace ===Prompt ========================================Promptset lines 200SELECT username, default_tablespace,temporary_tablespace,profile FROM dba_users order by 1;
set pages 8000set lines 280COL OWNER FOR a14col OBJECT_NAME for a36select OWNER,OBJECT_TYPE,OBJECT_NAME,STATUS from dba_objects where STATUS='INVALID';
select name,open_mode,log_mode,database_role,dbid from v\$database;
col host_name fOR a36col created fOR a16col start_time fOR a16col INSTANCE_NAME fOR a13col OPEN_MODE fOR a10set lines 280select d.name db_name,i.INSTANCE_NAME,i.HOST_NAME,d.open_mode,d.database_role,to_char(d.created,'DD-MON-YY HH24:MI') created,to_char(i.startup_time,'DD-MON-YY HH24:MI') start_time from v\$database d, gv\$instance i;spool off
EOF
Application Pre Backup Script
vi backup_files_R12.2.sh
#!/bin/sh########################################################################### Script : backup_files_R12.2.sh# Description : Script to Take Backup of Imp R12 Application Tier Files# Usage : ./backup_files_R12.2.sh# Creation Date : 01/04/2011# Created By : Nadhans Technologies## Revision History :#added backup of ohs files##########################################################################
## Define Variables##########################################################################today=`date +%Y%m%d`.`date +%H%M%S`; export today#BKP_DIR=$HOME/refresh_files_"$today"
HOST_NAME=`hostname`LOW_HOSTNAME=`echo ${HOST_NAME} | tr [A-Z] [a-z]`; export LOW_HOSTNAMEecho $LOW_HOSTNAME
## Set Environment###########################################################################. /mount/apps/apps_st/appl/APPSDEV_nadhans.env#. /mount/apps/apps_st/appl/APPSDEV_nadhans.env#. /data/app/EBSapps.env#choose_fs`grep -A 4 "function choose_fs" ~/.bash_profile | grep EBSapps.env`## Create Backup Directories##########################################################################
OHS_DIR=`grep s_ohs_instance_loc $CONTEXT_FILE | awk -F'[<>]' '{print $3}'` ; export OHS_DIROHS_DOMAIN=`grep s_ohs_component $CONTEXT_FILE | awk -F'[<>]' '{print $3}'` ; export OHS_DOMAINFS_TYPE=`grep s_file_edition_type $CONTEXT_FILE | awk -F'[<>]' '{print $3}'` ; export FS_TYPE
BKP_DIR=$HOME/refresh_files_"$FS_TYPE"_"$today"; export BKP_DIR
mkdir -p ${BKP_DIR}/applmkdir -p ${BKP_DIR}/10.1.2mkdir -p ${BKP_DIR}/10.1.3mkdir -p ${BKP_DIR}/instmkdir -p ${BKP_DIR}/ohs
## Backing up Application Tier Files##########################################################################echo "Starting : Backing up Application Tier Files : $today ..."echo "APPL_TOP is set to : $APPL_TOP ..."cp $APPL_TOP/*.env ${BKP_DIR}/appl/.cp $INST_TOP/appl/admin/*.env ${BKP_DIR}/inst/.cp $INST_TOP/appl/admin/*.xml ${BKP_DIR}/inst/.cp $INST_TOP/ora/10.1.2/*.env ${BKP_DIR}/10.1.2/.cp $INST_TOP/ora/10.1.2/network/admin/*.ora ${BKP_DIR}/10.1.2/.#cp $INST_TOP/ora/10.1.3/*.env ${BKP_DIR}/10.1.3/.#cp $INST_TOP/ora/10.1.3/network/admin/*.ora ${BKP_DIR}/10.1.3/.#cp $INST_TOP/admin/scripts/default_key.ini ${BKP_DIR}/inst/.
cp $OHS_DIR/config/OHS/$OHS_DOMAIN/apps.conf ${BKP_DIR}/ohs/cp $OHS_DIR/config/OHS/$OHS_DOMAIN/mod_wl_ohs.conf ${BKP_DIR}/ohs/cp $OHS_DIR/config/OHS/$OHS_DOMAIN/httpd.conf ${BKP_DIR}/ohs/
echo ""echo "####################################################################"echo ""echo "Finished : Backing up Application Tier Files : $today ..."echo ""echo "####################################################################"echo ""echo ""
Database Size & Growth
col "Database Size" format a20col "Free space" format a20col "Used space" format a20select round(sum(used.bytes) / 1024 / 1024 / 1024 ) || ' GB' "Database Size", round(sum(used.bytes) / 1024 / 1024 / 1024 ) -round(free.p / 1024 / 1024 / 1024) || ' GB' "Used space", round(free.p / 1024 / 1024 / 1024) || ' GB' "Free space"from (select bytesfrom v$datafileunion allselect bytesfrom v$tempfileunion allselect bytesfrom v$log) used, (select sum(bytes) as pfrom dba_free_space) freegroup by free.p/
Query 2
break on report on fsmtpt skip 1compute sum of mtptgb on reportcompute sum of nbrfiles on reportcompute sum of size_gb on reportcol fsmtpt format a8 trunccol size_gb format 99999.90col dftype format a15col nbrfiles format 9999999
select 'DATAFILES' dftype,count(*) nbrfiles,sum(bytes)/1024/1024/1024 size_gbfrom dba_data_files where tablespace_name not like '%UNDO%'group by substr(file_name,8,(instr(file_name,'/',9,1) -8))unionselect 'UNDO' dftype,count(*) nbrfiles, sum(bytes)/1024/1024/1024 size_gbfrom dba_data_files i where tablespace_name like '%UNDO%'group by substr(i.file_name,8,(instr(i.file_name,'/',9,1) -8))unionselect 'TEMPFILES' dftype,count(*) nbrfiles, sum(bytes)/1024/1024/1024 size_gbfrom dba_temp_files tgroup by substr(t.file_name,8,(instr(t.file_name,'/',9,1) -8))unionselect 'REDOLOGS' dftype, count(*) nbrfiles, sum(bytes)/1024/1024/1024 size_gbfrom v$log lg, v$logfile lfwhere lf.group# = lg.group#group by substr(lf.member,8,(instr(lf.member,'/',9,1) -8))unionselect 'CONTROLFILES' dftype, count(*) nbrfiles, 0 size_gbfrom v$controlfile cgroup by substr(c.name,8,(instr(c.name,'/',9,1) -8))order by 3/
Query 3
col "Database Size" format a20 col "Free space" format a20 col "Used space" format a20 select round(sum(used.bytes) / 1024 / 1024 / 1024 ) || ' GB' "Database Size" , round(sum(used.bytes) / 1024 / 1024 / 1024 ) - round(free.p / 1024 / 1024 / 1024) || ' GB' "Used space" , round(free.p / 1024 / 1024 / 1024) || ' GB' "Free space" from (select bytes from v$datafile union all select bytes from v$tempfile union all select bytes from v$log) used , (select sum(bytes) as p from dba_free_space) free group by free.p /
Find the size occupied by Data in a Database or Database usage detailsGives the size occupied by data in this database.
SELECT SUM (bytes) / 1024 / 1024 / 1024 AS GB FROM dba_segments;
SELECT SUM (bytes) / 1024 / 1024 / 1024 AS GB FROM dba_data_files;
Find out database growth in a year
select to_char(creation_time, 'RRRR Month') "Month",sum(bytes)/1024/1024/1024"Growth in Meg"from sys.v_$datafilewhere creation_time > SYSDATE-365group by to_char(creation_time, 'RRRR Month');
Find out database growth per Month
select to_char(creation_time, 'MM-RRRR') "Month", sum(bytes)/1024/1024/1024 "Growth in GBfrom sys.v_$datafilewhere to_char(creation_time,'RRRR')='&YEAR_IN_YYYY_FORMAT'group by to_char(creation_time, 'MM-RRRR')order by to_char(creation_time, 'MM-RRRR');
List of Data files:
select substr(name,1,instr(name,'/',-1)) path from v$datafileunionselect substr(member,1,instr(member,'/',-1)) path from v$logfileunionselect substr(name,1,instr(name,'/',-1)) path from v$controlfileunionselect substr(name,1,instr(name,'/',-1)) path from v$tempfile;
UTL_FILE_DIR 19C Database
1.Source the environment file $ source <CONTEXT_NAME>.env
2.Obtain the existing value for the UTL_FILE_DIR using the following commands:
perl $ORACLE_HOME/appsutil/bin/txkCfgUtlfileDir.pl -contextfile=/us5201/app/oracle/products/19.3.0/appsutil/nadhans.xml -oraclehome=$ORACLE_HOME -outdir=$ORACLE_HOME/appsutil/log -mode=setUtlFileDir -servicetype=onpremise
This will create a text file <DB_NAME>_utilfiledir.txt under the $ORACLE_HOME/dbs directory with references to the target oracle home.
3.Review the <DB_NAME>_utilfiledir.txt and edit the values ,if required .
4.Execute the following command to store the updated values for UTL_FILE_DIR in the database.
cd <ORACLE_HOME>/appsutil/bin
perl <ORACLE_HOME>/appsutil/bin/txkCfgUtlfileDir.pl -contextfile=<DB Context File> -oraclehome=<ORACLE_HOME> -outdir=<ORACLE_HOME>/appsutil/log -mode=setUtlFileDir
This command will validate the directory paths provided in the <DB_NAME>_utilfiledir.txt.
5.Execute the below command to create a directory object for the outbound directory (Pointed to by the s_outbound_dir context variable in the database tier context file)
perl $ORACLE_HOME/appsutil/bin/txkCfgUtlfileDir.pl -contextfile=/datamount/app/oracle/products/19.3.0/appsutil/NADHANS.xml -oraclehome=/datamount/app/oracle/products/19.3.0/appsutil/NADHANS.xml -outdir=/datamount/app/oracle/products/19.3.0/appsutil/NADHANS.xml/appsutil/log -mode=createDirObject
When prompted for the OS patch for the directory object to be created ,enter the values of the s_outbound_dir context variable in the database tier context file .
6.Sync up the values of UTL_FILE_DIR in the database tier context file by running the following command.
perl <ORACLE_HOME>/appsutil/bin/txkCfgUtlfileDir.pl -contextfile=<DB Context File> - oraclehome <ORACLE_HOME> -outdir= <ORACLE_HOME>/appsutil/log -mode=syncUtlFileDir -skipautoconfig=yes
Now source the PDB environment file in the database tier and re-run the autocoNfig .
Update Manually
grep -i "s_db_util_filedir" nadhans.xml
create or replace directory APPLTMP as '/mount/DEV/applptmp';
grant read,write on directory APPLTMP to apps;
insert into Apps.ebs_utlfile_param (NAME, VALUE) values ('utl_file_dir','/mount/DEV/applptmp');
1 row created.SQL> select value from apps.v$parameter where name='utl_file_dir';
VALUE--------------------------------------------------------------------------------/mount/DEV/applptmp
delete from Apps.ebs_utlfile_param (NAME, VALUE) values ('utl_file_dir','/mount/app/oracle/products/temp/DEV');
delete from Apps.ebs_utlfile_param where NAME='utl_file_dir' and VALUE='/mount/app/oracle/products/temp/DEV';
delete from apps.v$parameter where VALUE='/mount/app/oracle/products/temp/DEV';
update Apps.ebs_utlfile_param (NAME, VALUE) values ('utl_file_dir','/mount/DEV/applptmp');
Check if UTL_FILE and FND_FILE are working fine
UTL_FILEset serveroutput on DECLARE file_location VARCHAR2(256) := '<first entry on utl_file_dir>'; file_name VARCHAR2(256) := 'utlfile1.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; /
References: Metalink (MOS) Note ID: 261693.1
FND_FILEset serveroutput onexec FND_FILE.PUT_LINE(FND_FILE.LOG, 'THIS IS A TEST');
Services Create & Start
exec DBMS_SERVICE.CREATE_SERVICE(SERVICE_NAME=>'ebs_NADHANS', NETWORK_NAME=>'ebs_NADHANS');
exec dbms_service.START_SERVICE('ebs_NADHANS);
exec DBMS_SERVICE.CREATE_SERVICE(SERVICE_NAME=>'NADHANS_ebs_patch', NETWORK_NAME=>'NADHANS_ebs_patch');
exec dbms_service.START_SERVICE('NADHANS_ebs_patch');
Using UTL_FILE_DIR or Database Directories for PL/SQL File I/O in Oracle E-Business Suite Releases 12.1 and 12.2 (Doc ID 2525754.1)
SID&UNIX
sid.sql
id format 9999col username format a10col osuser format a10col program format a25col process format 9999999col spid format 999999col logon_time format a13
set lines 150
set heading offset verify offset feedback off
undefine sid_numberundefine spid_numberrem accept sid_number number prompt "pl_enter_sid:"
col sid NEW_VALUE sid_number noprintcol spid NEW_VALUE spid_number noprint
select s.sid sid, p.spid spid-- ,decode(count(*), 1,'null','No Session Found with this info') " " FROM v$session s, v$process p WHERE s.sid LIKE NVL('&sid', '%') AND p.spid LIKE NVL ('&OS_ProcessID', '%') AND s.process LIKE NVL('&Client_Process', '%') AND s.paddr = p.addr-- group by s.sid, p.spid;
PROMPT Session and Process InformationPROMPT -------------------------------
col event for a30
select ' SID : '||v.sid || chr(10)|| ' Serial Number : '||v.serial# || chr(10) || ' Oracle User Name : '||v.username || chr(10) || ' Client OS user name : '||v.osuser || chr(10) || ' Client Process ID : '||v.process || chr(10) || ' Client machine Name : '||v.machine || chr(10) || ' Oracle PID : '||p.pid || chr(10) || ' OS Process ID(spid) : '||p.spid || chr(10) || ' Session''s Status : '||v.status || chr(10) || ' Logon Time : '||to_char(v.logon_time, 'MM/DD HH24:MIpm') || chr(10) || ' Program Name : '||v.program || chr(10)from v$session v, v$process pwhere v.paddr = p.addrand v.serial# > 1and p.background is nulland p.username is not nulland sid = &sid_numberorder by logon_time, v.status, 1/
PROMPT Sql StatementPROMPT --------------
select sql_textfrom v$sqltext , v$sessionwhere v$sqltext.address = v$session.sql_addressand sid = &sid_numberorder by piece/
PROMPTPROMPT Event Wait InformationPROMPT ----------------------
select ' SID '|| &sid_number ||' is waiting on event : ' || x.event || chr(10) || ' P1 Text : ' || x.p1text || chr(10) || ' P1 Value : ' || x.p1 || chr(10) || ' P2 Text : ' || x.p2text || chr(10) || ' P2 Value : ' || x.p2 || chr(10) || ' P3 Text : ' || x.p3text || chr(10) || ' P3 Value : ' || x.p3from v$session_wait xwhere x.sid= &sid_number/
PROMPTPROMPT Session StatisticsPROMPT ------------------
select ' '|| b.name ||' : '||decode(b.name, 'redo size', round(a.value/1024/1024,2)||' M', a.value)from v$session s, v$sesstat a, v$statname bwhere a.statistic# = b.statistic#and name in ('redo size', 'parse count (total)', 'parse count (hard)', 'user commits')and s.sid = &sid_numberand a.sid = &sid_number--order by b.nameorder by decode(b.name, 'redo size', 1, 2), b.name/
COLUMN USERNAME FORMAT a10COLUMN status FORMAT a8column RBS_NAME format a10
PROMPTPROMPT Transaction and Rollback InformationPROMPT ------------------------------------
select ' Rollback Used : '||t.used_ublk*8192/1024/1024 ||' M' || chr(10) || ' Rollback Records : '||t.used_urec || chr(10)|| ' Rollback Segment Number : '||t.xidusn || chr(10)|| ' Rollback Segment Name : '||r.name || chr(10)|| ' Logical IOs : '||t.log_io || chr(10)|| ' Physical IOs : '||t.phy_io || chr(10)|| ' RBS Startng Extent ID : '||t.start_uext || chr(10)|| ' Transaction Start Time : '||t.start_time || chr(10)|| ' Transaction_Status : '||t.statusFROM v$transaction t, v$session s, v$rollname rWHERE t.addr = s.taddrand r.usn = t.xidusnand s.sid = &sid_number/
PROMPTPROMPT Sort InformationPROMPT ----------------
column username format a20column user format a20column tablespace format a20
SELECT ' Sort Space Used(8k block size is asssumed : '||u.blocks/1024*8 ||' M' || chr(10) || ' Sorting Tablespace : '||u.tablespace || chr(10)|| ' Sort Tablespace Type : '||u.contents || chr(10)|| ' Total Extents Used for Sorting : '||u.extentsFROM v$session s, v$sort_usage uWHERE s.saddr = u.session_addrAND s.sid = &sid_number/
set heading onset verify on
clear column
unix.sql
set echo offset serveroutput on size 999999set verify offset feedback offaccept uxproc prompt 'Enter Unix process id: 'DECLARE v_sid number; vs_cnt number; s sys.v_$session%ROWTYPE; p sys.v_$process%ROWTYPE; cursor cur_c1 is select sid from sys.v_$process p, sys.v_$session s where p.addr = s.paddr and (p.spid = &uxproc or s.process = '&uxproc');BEGIN dbms_output.put_line('====================================================================='); select nvl(count(sid),0) into vs_cnt from sys.v_$process p, sys.v_$session s where p.addr = s.paddr and (p.spid = &uxproc or s.process = '&uxproc'); dbms_output.put_line(to_char(vs_cnt)||' sessions were found with '||'&uxproc'||' as their unix process id.'); dbms_output.put_line('====================================================================='); open cur_c1; LOOP FETCH cur_c1 INTO v_sid; EXIT WHEN (cur_c1%NOTFOUND); select * into s from sys.v_$session where sid = v_sid; select * into p from sys.v_$process where addr = s.paddr; dbms_output.put_line('SID/Serial : '|| s.sid||','||s.serial#); dbms_output.put_line('Foreground : '|| 'PID: '||s.process||' - '||s.program); dbms_output.put_line('Shadow : '|| 'PID: '||p.spid||' - '||p.program); dbms_output.put_line('Terminal : '|| s.terminal || '/ ' || p.terminal); dbms_output.put_line('OS User : '|| s.osuser||' on '||s.machine); dbms_output.put_line('Ora User : '|| s.username); dbms_output.put_line('Details : '|| s.action||' - '||s.module); dbms_output.put_line('Status Flags: '|| s.status||' '||s.server||' '||s.type); dbms_output.put_line('Tran Active : '|| nvl(s.taddr, 'NONE')); dbms_output.put_line('Login Time : '|| to_char(s.logon_time, 'Dy HH24:MI:SS')); dbms_output.put_line('Last Call : '|| to_char(sysdate-(s.last_call_et/60/60/24), 'Dy HH24:MI:SS') || ' - ' || to_char(s.last_call_et/60, '99990.0') || ' min'); dbms_output.put_line('Lock/ Latch : '|| nvl(s.lockwait, 'NONE')||'/ '||nvl(p.latchwait, 'NONE')); dbms_output.put_line('Latch Spin : '|| nvl(p.latchspin, 'NONE')); dbms_output.put_line('SQLID : '|| s.sql_id); dbms_output.put_line('Current SQL statement:'); for c1 in ( select * from sys.v_$sqltext where HASH_VALUE = s.sql_hash_value order by piece) loop dbms_output.put_line(chr(9)||c1.sql_text); end loop; dbms_output.put_line('Previous SQL statement:'); for c1 in ( select * from sys.v_$sqltext where HASH_VALUE = s.prev_hash_value order by piece) loop dbms_output.put_line(chr(9)||c1.sql_text); end loop; dbms_output.put_line('Session Waits:'); for c1 in ( select * from sys.v_$session_wait where sid = s.sid) loop dbms_output.put_line(chr(9)||c1.state||': '||c1.event); end loop;-- dbms_output.put_line('Connect Info:');-- for c1 in ( select * from sys.v_$session_connect_info where sid = s.sid) loop-- dbms_output.put_line(chr(9)||': '||c1.network_service_banner);-- end loop; dbms_output.put_line('Locks:'); for c1 in ( select /*+ RULE */ decode(l.type, -- Long locks 'TM', 'DML/DATA ENQ', 'TX', 'TRANSAC ENQ', 'UL', 'PLS USR LOCK', -- Short locks 'BL', 'BUF HASH TBL', 'CF', 'CONTROL FILE', 'CI', 'CROSS INST F', 'DF', 'DATA FILE ', 'CU', 'CURSOR BIND ', 'DL', 'DIRECT LOAD ', 'DM', 'MOUNT/STRTUP', 'DR', 'RECO LOCK ', 'DX', 'DISTRIB TRAN', 'FS', 'FILE SET ', 'IN', 'INSTANCE NUM', 'FI', 'SGA OPN FILE', 'IR', 'INSTCE RECVR', 'IS', 'GET STATE ', 'IV', 'LIBCACHE INV', 'KK', 'LOG SW KICK ', 'LS', 'LOG SWITCH ', 'MM', 'MOUNT DEF ', 'MR', 'MEDIA RECVRY', 'PF', 'PWFILE ENQ ', 'PR', 'PROCESS STRT', 'RT', 'REDO THREAD ', 'SC', 'SCN ENQ ', 'RW', 'ROW WAIT ', 'SM', 'SMON LOCK ', 'SN', 'SEQNO INSTCE', 'SQ', 'SEQNO ENQ ', 'ST', 'SPACE TRANSC', 'SV', 'SEQNO VALUE ', 'TA', 'GENERIC ENQ ', 'TD', 'DLL ENQ ', 'TE', 'EXTEND SEG ', 'TS', 'TEMP SEGMENT', 'TT', 'TEMP TABLE ', 'UN', 'USER NAME ', 'WL', 'WRITE REDO ', 'TYPE='||l.type) type,decode(l.lmode, 0, 'NONE', 1, 'NULL', 2, 'RS', 3, 'RX',4, 'S', 5, 'RSX', 6, 'X',to_char(l.lmode) ) lmode,decode(l.request, 0, 'NONE', 1, 'NULL', 2, 'RS', 3, 'RX',4, 'S', 5, 'RSX', 6, 'X',to_char(l.request) ) lrequest,decode(l.type, 'MR', o.name,'TD', o.name,'TM', o.name,'RW', 'FILE#='||substr(l.id1,1,3)||' BLOCK#='||substr(l.id1,4,5)||' ROW='||l.id2,'TX', 'RS+SLOT#'||l.id1||' WRP#'||l.id2,'WL', 'REDO LOG FILE#='||l.id1,'RT', 'THREAD='||l.id1,'TS', decode(l.id2, 0, 'ENQUEUE', 'NEW BLOCK ALLOCATION'),'ID1='||l.id1||' ID2='||l.id2) objname from sys.v_$lock l, sys.obj$ o where sid = s.sid and l.id1 = o.obj#(+) ) loop dbms_output.put_line(chr(9)||c1.type||' H: '||c1.lmode||' R: '||c1.lrequest||' - '||c1.objname); end loop; dbms_output.put_line('====================================================================='); END LOOP; dbms_output.put_line(to_char(vs_cnt)||' sessions were found with '||'&uxproc'||' as their unix process id.'); dbms_output.put_line('Please scroll up to see details of all the sessions.'); dbms_output.put_line('====================================================================='); close cur_c1;exception when no_data_found then dbms_output.put_line('Unable to find process id &&uxproc!!!'); dbms_output.put_line('====================================================================='); return; when others then dbms_output.put_line(sqlerrm); return;END;/undef uxprocset heading onset verify onset feedback onset echo onRestore Point
Estimate Archive Size:
SELECT SUM_ARCH.DAY,
SUM_ARCH.GENERATED_GB,
SUM_ARCH_DEL.DELETED_GB,
SUM_ARCH.GENERATED_GB - SUM_ARCH_DEL.DELETED_GB "REMAINING_GB"
FROM ( SELECT TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY') DAY,
SUM (ROUND ( (blocks * block_size) / (1024 * 1024 * 1024), 2))
GENERATED_GB
FROM V$ARCHIVED_LOG
WHERE ARCHIVED = 'YES'
GROUP BY TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY')) SUM_ARCH,
( SELECT TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY') DAY,
SUM (ROUND ( (blocks * block_size) / (1024 * 1024 * 1024), 2))
DELETED_GB
FROM V$ARCHIVED_LOG
WHERE ARCHIVED = 'YES' AND DELETED = 'YES'
GROUP BY TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY')) SUM_ARCH_DEL
WHERE SUM_ARCH.DAY = SUM_ARCH_DEL.DAY(+)
ORDER BY TO_DATE (DAY, 'DD/MM/YYYY');
Show parameter reco;
Show parameter dest_1;
alter system set db_recovery_file_dest='/prodarch/oradata/nadhans/' scope=both;
create restore point BEFORE_PATCHING guarantee flashback database;
select * from v$restore_point;
Drop Restore Point :
drop restore point BEFORE_PATCHING;
CMS HOLD
1.Connect as apps user, Drop old table (jobs_already_on_hold)
drop table jobs_already_on_hold;
2. List out the Jobs which were already on HOLD
select request_id, phase_code, status_code from fnd_concurrent_requests where hold_flag = 'Y';
3.Create backup of the table with the jobs which were already ON HOLD.
create table jobs_already_on_hold as (select request_id, phase_code, status_code from fnd_concurrent_requests where hold_flag = 'Y');
select count(*) from jobs_already_on_hold;
select * from jobs_already_on_hold;
================
Running Conc Req
================
set echo off pages 100 lines 202
column REQUEST heading 'Request' format a9
column PHASE heading 'Phase' format A8
column STATUS heading 'Status' format A8
column PROGRAM heading 'Program Name' format A40
column SHORT heading 'Short Name' format A15
column REQUESTOR heading 'Requestor' format A15
column START_TIME heading 'Start Time' format A15
column RUN_TIME justify left heading 'Time(e)' format 999999.9
column OSPID heading 'OSPID' format a5
column OS_PIDa heading 'OSPIDA' format a6
column SID heading 'SID' format 99999
column serial# heading 'Serial#' format 99999
select substr(fcrv.request_id,1,9)REQUEST,
decode(fcrv.phase_code,'P','Pending','R','Running','I','Inactive','Completed')PHASE,
decode(fcrv.status_code,
'A','Waiting',
'B','Resuming',
'C','Normal',
'F','Scheduled',
'G','Warning',
'H','On Hold',
'I','Normal',
'M','No Manager',
'Q','Standby',
'R','Normal',
'S','Suspended',
'T','Terminating',
'U','Disabled',
'W','Paused',
'X','Terminated',
'Z','Waiting',fcrv.status_code)STATUS,
substr(fcrv.program,1,40)PROGRAM,
substr(fcrv.PROGRAM_SHORT_NAME,1,15)SHORT,
substr(fcrv.requestor,1,15)REQUESTOR,
-- to_char(fcrv.actual_start_date,'MM/DD/RR HH24:MI')START_TIME,
round(((sysdate - fcrv.actual_start_date)*1440),1)RUN_TIME,
substr(fcr.oracle_process_id,1,7)OSPID,
s.sid,s.serial#
--substr(fcr.os_process_id,1,7)OS_PIDa
from apps.fnd_conc_req_summary_v fcrv,
apps.fnd_concurrent_requests fcr,
v$session s,
v$process p
where fcrv.phase_code = 'R'
and fcrv.request_id = fcr.request_id
and s.paddr = p.addr
and fcr.oracle_process_id = p.spid
and fcrv.concurrent_program_id not in ('40112','40113','36887')
--and trunc(fcrv.actual_start_date) like trunc(sysdate)
order by PHASE, STATUS, REQUEST desc;
======================================================================
SELECT REQUEST_ID,
PHASE_CODE,
STATUS_CODE,
HAS_SUB_REQUEST,
IS_SUB_REQUEST,
hold_flag,
REQ_INFORMATION
FROM apps.fnd_concurrent_requests
WHERE (phase_code = 'P' AND hold_flag = 'N')
OR phase_code = 'R'
OR status_code = 'W';
=========================================================================
4.Now, Place the pending jobs on HOLD using the below update command.
SQL> update fnd_concurrent_requests set hold_flag = 'Y' where phase_code ='P' and hold_flag ='N';
5.After Putting the Jobs ON HOLD, now verify if any Running Requests with PAUSED Status.
If there are any Running requests with PAUSED status,
please verify the child requests status of this Program.
If there were any put on HOLD as part of the putting Jobs on Hold process.
Release them from HOLD and process the requests.
6.Check again the pending scheduled program during the time frame 3 PM to 5 PM CST
7.Please ensure to check the below query for every 5 minutes until it returns 0 rows.
List the pending ,running and passed requests
select REQUEST_ID,PHASE_CODE,STATUS_CODE,HAS_SUB_REQUEST,IS_SUB_REQUEST,hold_flag,REQ_INFORMATION from apps.fnd_concurrent_requests where (phase_code = 'P' and hold_flag = 'N' ) or phase_code = 'R' or status_code='W';
select count(1) from apps.fnd_concurrent_requests where ( phase_code ='P' and hold_flag ='N') or phase_code ='R';
Relese jobs script:
Connect as apps user and perform the below
update fnd_concurrent_requests set hold_flag = 'N' where hold_flag = 'Y' and request_id not in (select request_id from jobs_already_on_hold);
commit;
Archive Log & DR
PROD
select thread#,max(sequence#) from v$archived_log where resetlogs_change#=(select resetlogs_change# from v$database) group by thread#;
select thread#,max(sequence#) from v$archived_log where resetlogs_change#=(select resetlogs_change# from v$database) group by thread#;
DR
select arch.thread# "thread", arch.sequence# "last sequence received", appl.sequence# "last sequence applied", (arch.sequence# - appl.sequence#) "difference"
from(select thread# ,sequence# from v$archived_log where (thread#,first_time ) in (select thread#,max(first_time) from v$archived_log group by thread#)) arch,
(select thread# ,sequence# from v$log_history where (thread#,first_time ) in (select thread#,max(first_time) from v$log_history group by thread#)) appl
where arch.thread# = appl.thread# order by 1;
Select NAME,ROTECTION_MODE,ROTECTION_LEVEL From V$DATABASE;
select PROCESS,STATUS,THREAD#,SEQUENCE# from v$managed_standby;
select PROCESS,STATUS,THREAD#,SEQUENCE#,BLOCK# from v$managed_standby;
SQL> select database_role from v$database ;
DATABASE_ROLE
----------------
PHYSICAL STANDBY
SQL> alter database register logfile '/us9000/archive06/backup_new/file06dec/thread_1_seq_1803.355.994039841' ;
Database altered.
SQL> alter database register logfile '/us9000/archive06/backup_new/thread_1_seq_1802.356.994039735' ;
alter database register logfile '/us9000/archive06/backup_new/thread_1_seq_1802.356.994039735'
*
ERROR at line 1:
ORA-00308: cannot open archived log
'/us9000/archive06/backup_new/thread_1_seq_1802.356.994039735'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
delete archivelog all completed before 'sysdate-25';
DELETE ARCHIVELOG UNTIL SEQUENCE 14710;
delete archivelog until sequence 20; backed up 1 times to device type sbt;
delete archivelog until time 'SYSDATE-1';
find . -name "*.log" -mtime +10 -exec rm {} \;
delete force noprompt archivelog all backed up 2 times to device type sbt completed before 'sysdate-1/4';
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
alter database recover managed standby database using current logfile disconnect
SELECT PROCESS, STATUS FROM V$MANAGED_STANDBY;
alter system set log_archive_dest_state_2=
select xmltransform(dbms_qopatch.is_patch_installed('25869830'), dbms_qopatch.get_opatch_xslt) "Patch installed?" from dual;
Decrypt Weblogic Password
Step 1:
cd $EBS_DOMAIN_HOME/security
vi decrypt_password.py
from weblogic.security.internal import *
from weblogic.security.internal.encryption import *
encryptionService = SerializedSystemIni.getEncryptionService(".")
clearOrEncryptService = ClearOrEncryptedService(encryptionService)
# Take encrypt password from user
pwd = raw_input("Paste encrypted password ({AES}fk9EK...): ")
# Delete unnecessary escape characters
preppwd = pwd.replace("\\", "")
# Display password
print "Decrypted string is: " + clearOrEncryptService.decrypt(preppwd)
Step2:
Source wls environment file:
. $FMW_HOME/wlserver_10.3/server/bin/setWLSEnv.sh
STEP 3:
[applmgr@testenv security]$ java weblogic.WLST decrypt_password.py
Initializing WebLogic Scripting Tool (WLST) ...
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
Paste encrypted password ({AES}fk9EK...): {AES}PVXB/uhJyeFDjoJmFqZHg8k+vW6/hACDcP6KugEmGX4=
Decrypted string is: *******
Invalid Objects
find . -name "*.req" -mtime +30 -exec rm {} \; &
select count(*) from dba_objects where status='INVALID';
select comp_id,status from dba_registry;
exec sys.utl_recomp.recomp_parallel(10);
select object_name, object_type, owner, LAST_DDL_TIME,status from dba_objects where status = 'INVALID' and object_name||owner not in (select object_name||owner from invalid_Objects_10DEC22);
select object_name, object_type, owner, LAST_DDL_TIME,status from dba_objects where status = 'INVALID' and object_name||owner not in (select object_name||owner from 31AUG2022);
select object_name, object_type, owner, LAST_DDL_TIME,status from dba_objects where status = 'INVALID' and object_name||owner not in (select object_name||owner from invalid_Objects_JUL_2021);
col OBJECT_NAME for a30
col OWNER for a20
select BUG_NUMBER,BUG_ID,CREATION_DATE,LANGUAGE,CREATED_BY from ad_bugs where BUG_NUMBER in ('33128953','33372456');
select BUG_NUMBER,BUG_ID,CREATION_DATE,LANGUAGE,CREATED_BY from apps.ad_bugs where BUG_NUMBER='&a';
select BUG_NUMBER,BUG_ID,CREATION_DATE,LANGUAGE,CREATED_BY from ad_bugs where BUG_NUMBER in('33782739','33623398');,'30735865','31904550');,'28969483','29143795','30144049','31006617','31165250','30868356');
select BUG_NUMBER,BUG_ID,CREATION_DATE,LANGUAGE,CREATED_BY from ad_bugs where BUG_NUMBER in ('30628681','30735865')';,'32181474','32266274','32433768')
select OBJECT_NAME,OWNER,OBJECT_TYPE,LAST_DDL_TIME,STATUS from dba_objects where OBJECT_NAME in ('XXPMRY_AP_SELF_ASSESS_TAX_REV','@AP_CUSTOM_INV_VALIDATION_PKG')l,'XXNHR_NTM_TXN_PKG','XXNHR_SUBINV_TRANSFER_PKG','NHR_APPLY_HOLD');
select object_name,object_type,owner,LAST_DDL_TIME,status from dba_objects where status = 'INVALID'
select * from AD_BUGS where bug_number='30273541';
create table dba_objects_B4 as select * from dba_objects where status='INVALID';
select BUG_NUMBER,BUG_ID,CREATION_DATE,LANGUAGE,CREATED_BY from ad_bugs where BUG_NUMBER in ('33782739','33168635','33625264')','30144049','30144066','30868356','31006617','31165250')
select BUG_NUMBER,BUG_ID,CREATION_DATE,LANGUAGE,CREATED_BY from ad_bugs where BUG_NUMBER in ('32438203','28840844','32840432','32460404','31206584'); ','32117360','30980446','32004048','32636526');
select name,open_mode,log_mode,database_role,dbid from v$database;
set lines 200 pages 200
col OBJECT_NAME for a30
col OWNER for a20
select OBJECT_NAME,OWNER,OBJECT_TYPE,LAST_DDL_TIME,STATUS from dba_objects where OBJECT_NAME='CFZ_REP_COMMON_PKG';
select BUG_NUMBER,BUG_ID,CREATION_DATE,LANGUAGE,CREATED_BY from ad_bugs where BUG_NUMBER in('32071646','32117360','32004048');,'31667105');,'28969483','29143795','30144049','31006617','31165250','30868356');
find . -name "*.log" -mtime +10 -exec rm {} \;
find . -type f -name "file to delete" -exec rm -f {} ;
find . -name "*.trc" -mtime +7 -type f -exec mv "{}" /shared/tracefiles_23_Aug_21/ \; &
SELECT owner, index_name, tablespace_name
FROM dba_indexes
WHERE status = 'UNUSABLE';
ls -lShr | tail -30
select object_name from dba_objects where status like 'INVALID' minus select object_name from dba_objects_backup;
After Upgrading Database to 19c Running AutoConfig on Database Tier Ends in "ORA-01034: ORACLE not available" and "ORA-27101: shared memory realm does not exist" Error (Doc ID 2748893.1) To BottomTo Bottom
PROD_INVALIDS:
select object_name, object_type, owner, LAST_DDL_TIME,status from dba_objects where status = 'INVALID' and object_name||owner not in (select object_name||owner from dba_objectsbkpsep15);
SELECT DISTINCT sql_id, plan_hash_value
FROM dba_hist_sqlstat dhs,
(
SELECT /*+ NO_MERGE */ MIN(snap_id) min_snap, MAX(snap_id) max_snap
FROM dba_hist_snapshot ss
WHERE ss.begin_interval_time BETWEEN (SYSDATE - &No_Days) AND SYSDATE
) s
WHERE dhs.snap_id BETWEEN s.min_snap AND s.max_snap
AND dhs.sql_id IN ( '&SQLID')
30433124,31349591,31349591_ESA:u31349591.drv,31349591_PTB:u31349591.drv,31800803,33346385,28732161,28732161_PTB:u28732161.drv,28732161_ESA:u28732161.drv,31088182,31088182_PTB:u31088182.drv,31088182_ESA:u31088182.drv
select BUG_NUMBER,BUG_ID,CREATION_DATE,LANGUAGE,CREATED_BY from ad_bugs where BUG_NUMBER in ('25452805','26052406','26521736','30433124','31349591','31800803','33346385','28732161','31088182')
USER DDL
cat user_ddl.sqlset longchunksize 20000 pagesize 0 feedback off verify off trimspool oncolumn Extracted_DDL format a1000
EXEC DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'PRETTY',TRUE);EXEC DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',TRUE);
undefine User_in_Uppercase;define User_in_Uppercase=&&userset linesize 1000set long 2000000000select (casewhen ((select count(*)from dba_userswhere username = '&&User_in_Uppercase' and profile <> 'DEFAULT') > 0)then chr(10)||' -- Note: Profile'||(select dbms_metadata.get_ddl('PROFILE', u.profile) AS ddl from dba_users u where u.username = '&User_in_Uppercase')else to_clob (chr(10)||' -- Note: Default profile, no need to create!')end ) from dualUNION ALLselect (casewhen ((select count(*)from dba_userswhere username = '&User_in_Uppercase') > 0)then ' -- Note: Create user statement'||dbms_metadata.get_ddl ('USER', '&User_in_Uppercase')else to_clob (chr(10)||' -- Note: User not found!')end ) Extracted_DDL from dualUNION ALLselect (casewhen ((select count(*)from dba_ts_quotaswhere username = '&User_in_Uppercase') > 0)then ' -- Note: TBS quota'||dbms_metadata.get_granted_ddl( 'TABLESPACE_QUOTA', '&User_in_Uppercase')else to_clob (chr(10)||' -- Note: No TS Quotas found!')end ) from dualUNION ALLselect (casewhen ((select count(*)from dba_role_privswhere grantee = '&User_in_Uppercase') > 0)then ' -- Note: Roles'||dbms_metadata.get_granted_ddl ('ROLE_GRANT', '&User_in_Uppercase')else to_clob (chr(10)||' -- Note: No granted Roles found!')end ) from dualUNION ALLselect (casewhen ((select count(*)from V$PWFILE_USERSwhere username = '&User_in_Uppercase' and SYSDBA='TRUE') > 0)then ' -- Note: sysdba'||chr(10)||to_clob (' GRANT SYSDBA TO '||'"'||'&User_in_Uppercase'||'"'||';')else to_clob (chr(10)||' -- Note: No sysdba administrative Privilege found!')end ) from dualUNION ALLselect (casewhen ((select count(*)from dba_sys_privswhere grantee = '&User_in_Uppercase') > 0)then ' -- Note: System Privileges'||dbms_metadata.get_granted_ddl ('SYSTEM_GRANT', '&User_in_Uppercase')else to_clob (chr(10)||' -- Note: No System Privileges found!')end ) from dualUNION ALLselect (casewhen ((select count(*)from dba_tab_privswhere grantee = '&User_in_Uppercase') > 0)then ' -- Note: Object Privileges'||dbms_metadata.get_granted_ddl ('OBJECT_GRANT', '&User_in_Uppercase')else to_clob (chr(10)||' -- Note: No Object Privileges found!')end ) from dual/
Package Body
COL owner NEW_VALUE owner FORMAT A30;COL name NEW_VALUE name FORMAT A30;COL type NEW_VALUE type FORMAT A12;
prompt prompt Spool the defintion onto a filepromptaccept owner prompt 'enter owner ( default - TIMEINC ) :- ' default TIMEINCaccept obj_name prompt 'enter object name :- '
SET VER OFF FEED OFF;
SELECT owner owner, object_name name, object_type type FROM dba_objects WHERE owner LIKE RTRIM(UPPER('&&owner'))||'%' AND object_name LIKE RTRIM(UPPER('&&obj_name'))||'%' AND object_type IN ('PACKAGE BODY', 'FUNCTION', 'PROCEDURE', 'TRIGGER') AND ROWNUM = 1;
PROPRO Generating spool file for &&type &&namePRO
SET TERM OFF PAGES 0 LIN 4000 TRIMS ON;SPO BODY_&&owner..&&name..SQL;SELECT DECODE(line,1,'CREATE OR REPLACE ',NULL)|| text FROM dba_source WHERE owner = '&&owner' AND name = '&&name' AND type = '&&type' ORDER BY line;PRO /SPO OFF;SET TERM ON PAGES 200 LIN 200 VER ON FEED ON DOC ON;prompt ---------------------------------------------------------------;prompt See : BODY_&&owner..&&name..SQLprompt ---------------------------------------------------------------;promptUNDEF 1 name type;CLE COL;
Package Specification
COL owner NEW_VALUE owner FORMAT A30;COL name NEW_VALUE name FORMAT A30;COL type NEW_VALUE type FORMAT A12;
prompt prompt Spool the defintion onto a filepromptaccept owner prompt 'enter owner ( default - BOOKER ) :- ' default BOOKERaccept obj_name prompt 'enter object name :- '
SET VER OFF FEED OFF;
SELECT owner owner, object_name name, object_type type FROM dba_objects WHERE owner LIKE RTRIM(UPPER('&&owner'))||'%' AND object_name LIKE RTRIM(UPPER('&&obj_name'))||'%' AND object_type IN ('PACKAGE', 'FUNCTION', 'PROCEDURE', 'TRIGGER') AND ROWNUM = 1;
PROPRO Generating spool file for &&type &&namePRO
SET TERM OFF PAGES 0 LIN 4000 TRIMS ON;SPO DEF_&&owner..&&name..SQL;SELECT DECODE(line,1,'CREATE OR REPLACE ',NULL)|| text FROM dba_source WHERE owner = '&&owner' AND name = '&&name' AND type = '&&type' ORDER BY line;PRO /SPO OFF;SET TERM ON PAGES 200 LIN 200 VER ON FEED ON DOC ON;prompt ---------------------------------------------------------------;prompt See : DEF_&&owner..&&name..SQLprompt ---------------------------------------------------------------;promptUNDEF 1 name type;CLE COL;
Tuning Advisor
Running Sql Advisor for SIDSuppose the sql id is – 87s8z2zzpsg881. Create Tuning TaskDECLAREl_sql_tune_task_id VARCHAR2(100);BEGINl_sql_tune_task_id := DBMS_SQLTUNE.create_tuning_task (sql_id => '87s8z2zzpsg88',scope => DBMS_SQLTUNE.scope_comprehensive,time_limit => 500,task_name => '87s8z2zzpsg88_tuning_task11',description => 'Tuning task1 for statement 87s8z2zzpsg88');DBMS_OUTPUT.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id);END;/
2. Execute Tuning task:EXEC DBMS_SQLTUNE.execute_tuning_task(task_name => '87s8z2zzpsg88_tuning_task11');
3. Get the Tuning advisor report.
set long 65536set longchunksize 65536set linesize 100select dbms_sqltune.report_tuning_task('87s8z2zzpsg88_tuning_task11') from dual;
4. Get list of tuning task present in database:We can get the list of tuning tasks present in database from DBA_ADVISOR_LOGSELECT TASK_NAME, STATUS FROM DBA_ADVISOR_LOG WHERE TASK_NAME ;
5. Drop a tuning task:execute dbms_sqltune.drop_tuning_task('87s8z2zzpsg88_tuning_task11');
------------------------------------------------------------------------------------------------------------------------------------
SQL> execute dbms_stats.gather_table_stats(ownname => 'XLA', tabname =>'XLA_VALIDATION_LINES_GT', estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE, method_opt => 'FOR ALL COLUMNS SIZE AUTO');
PL/SQL procedure successfully completed.
SQL> execute dbms_sqltune.accept_sql_profile(task_name =>'2r69btunk8kdd_tuning_task11', task_owner => 'APPS', replace => TRUE);
PL/SQL procedure successfully completed.
View Backup
-------------------------------------------------------------------------------------------
select object_name, object_type, owner, LAST_DDL_TIME from dba_objects where status = 'INVALID' and object_name||owner not in (select object_name||owner from dba_objects_bkp18);
-----------------------------------------------------------------------------------------
select job,PRIV_USER,INSTANCE,failures,broken,LAST_DATE,WHAT,JOB_NAME from dba_jobs where job=14531;
set heading off;set echo off;Set pages 999;set long 90000;select dbms_metadata.get_ddl('SYNONYM','AP_UNDO_INVOICES','APPS') from dual;
CREATE OR REPLACE EDITIONABLE SYNONYM "APPS"."AP_UNDO_INVOICES" FOR "BOLINF"."AP_UNDO_INVOICES#"