Useful Scripts For APPS DBA
Useful Scripts For APPS DBA
com
Queries for
Apps DBA
It contains important
queries for APPS DBA
day to day operation
Techgoeasy.com
1 [Queries for Apps DBA]
Apps Queries
Version information
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use
only.
2 [Queries for Apps DBA]
Materialized view
set pages 52
set verify off
set term on
set feedback off
col APP NAME format a10
col filename format a15
col version format a15
col last_update_date format a15
set linesize 90
select af.app_short_name APP NAME,
af.filename,
afv.version,
afv.LAST_UPDATE_DATE
from ad_files af,
ad_file_versions afv
where af.file_id = afv.file_id and
af.filename like &1
order by afv.LAST_UPDATE_DATE desc
/
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use
only.
3 [Queries for Apps DBA]
The package version return from above query can be checked with the version of file in
$APPL_TOP
Useful Printer Query for apps
Printer Queries
SELECT PRINTER_DRIVER_NAME,
USER_PRINTER_DRIVER_NAME ,
PRINTER_DRIVER_METHOD_CODE ,
SPOOL_FLAG ,
SRW_DRIVER ,
COMMAND_NAME ,
ARGUMENTS ,
INITIALIZATION , RESET
FROM apps.FND_PRINTER_DRIVERS
WHERE PRINTER_DRIVER_NAME =( SELECT PRINTER_DRIVER FROM apps.FND_PRINTER_INFORMATION
WHERE PRINTER_STYLE=( SELECT PRINT_STYLE FROM apps.FND_CONCURRENT_REQUESTS WHERE
REQUEST_ID= &1 AND PRINTER_TYPE=( SELECT PRINTER_TYPE FROM apps.FND_PRINTER WHERE
The log files are located
PRINTER_NAME=( in $LOG_HOME ($INST_TOP/logs) in Oracle Applications R12
SELECT PRINTER
Database Tier
FROM apps.FND_CONCURRENT_REQUESTS WHERE REQUEST_ID= &REQID)) );
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use
only.
4 [Queries for Apps DBA]
Application Tier
Apache Logs (10.1.3 Oracle Home which is equivalent to iAS Oracle Home - Apache, OC4J
and OPMN)
$LOG_HOME/ora/10.1.3/Apache - > Location for Apache Error and Access log files
$LOG_HOME/ora/10.1.3/j2ee - > location for j2ee related log files
$LOG_HOME/ora/10.1.3/opmn - > location for opmn related log files
Forms & Reports related logs (10.1.2 Oracle home which is equivalent to 806 Oracle
Home)
$LOG_HOME/ora/10.1.2/forms
$LOG_HOME/ora/10.1.2/reports
Startup/Shutdown Log files location:
$INST_TOP/logs/appl/admin/log
Patch log files location:
$APPL_TOP/admin/$TWO_TASK/log/
Logs for the adpreclone.pl are located:
$INST_TOP/admin/log/StageAppsTier_< timestamp >.log
Where the logs for the admkappsutil.pl are located?
$INST_TOP/admin/log/MakeAppsUtil_< timestamp >.log
Logs for the adcfgclone.pl are located:
$INST_TOP/admin/log/ApplyAppsTier_< timestamp >.log
Logs for the adconfig are located:
$INST_TOP/admin/log/< timestamp >/adconfig.log
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use
only.
5 [Queries for Apps DBA]
Sql to check Workflow Agent Listener/WF Java Deferred Agent Listeners are running
STARTUP_MODE,
CONTAINER_TYPE,
INBOUND_AGENT_NAME,
OUTBOUND_AGENT_NAME,
CORRELATION_ID,
MAX_IDLE_TIME
from FND_SVC_COMPONENTS
order by COMPONENT_NAME
/
A) To find total number of open database connections for a given JVM PID
SELECT s.process, Count(*) all_count FROM v$session s WHERE s.process IN () GROUP BY
s.process
B) To find number of database connections per JVM that were inactive for longer then 30
minutes
SELECT s.process, Count(*) olderConnection_count FROM v$session s WHERE s.process IN ()
and s.last_call_et>=(30*60) and s.status='INACTIVE' GROUP BY s.process
prompt ~~~~
select count(*), machine, process, module from v$session
where program like 'JDBC%' group by machine, process, module order by 1 asc
/
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use
only.
7 [Queries for Apps DBA]
select substr(APPLICATION_SHORT_NAME,1,10)
Product,substr(BUG_NUMBER,1,10),Version,last_update_date applied_date from ad_bugs
where BUG_NUMBER= to_char('&bug_no');
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use
only.
8 [Queries for Apps DBA]
This script helps in identifying the various versions of a particular file, the associated BUG
NUMBERS, the Date on which it was applied.Input is the FILE NAME whose VERSION is to be
determined
ad_applied_patches e,
ad_patch_run_bug_actions f,
ad_file_versions g,
ad_files h
where a.bug_id = b.bug_id
and b.patch_run_id = c.patch_run_id
and c.patch_driver_id = d.patch_driver_id
and d.applied_patch_id = e.applied_patch_id
and b.patch_run_bug_id = f.patch_run_bug_id
and f.patch_file_version_id = g.file_version_id
and g.file_id = h.file_id
and h.filename='&File_Name'
order by c.end_date desc
/
You can tell if you're on OAF 5.7 version OAF 5.10 on the database tier by running the
following SQL:
select jdr_mds_internal.getRepositoryVersion from dual;
If it returns something like 9.0.3.6.0_### then you are on OAF 5.7. If it
returns 9.0.5.0.0_### then you are on OAF 5.10.
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use
only.
10 [Queries for Apps DBA]
from
fnd_application a,
fnd_product_installations p,
fnd_oracle_userid o
where
a.application_id = p.application_id and
p.oracle_id = o.oracle_id
/
To determine dependency
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use
only.
12 [Queries for Apps DBA]
Application level
select
a.PROFILE_OPTION_ID,a.PROFILE_OPTION_NAME,b.USER_PROFILE_OPTION_NAME,c.PROFILE_
OPTION_VALUE from fnd_profile_options a,fnd_profile_options_tl b
,fnd_profile_option_values c where a.PROFILE_OPTION_NAME=b.PROFILE_OPTION_NAME and
a.PROFILE_OPTION_ID=c.PROFILE_OPTION_ID and b.LANGUAGE='US' and c.LEVEL_ID=10002
and c.level_value='&2' b.USER_PROFILE_OPTION_NAME like '&1';
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use
only.
13 [Queries for Apps DBA]
Check messages
select message_text from fnd_new_messages m, fnd_application a
where upper('&message_name') = m.message_name
and upper('&language_code') = m.language_code
and upper('&application_short_name') = a.application_short_name
and m.application_id = a.application_id
/
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use
only.
14 [Queries for Apps DBA]
10003, 'Responsibility',
10004, 'User',
'UnDef') LEVEL_SET,
v.level_value LEVEL_VAL,
v.profile_option_value VALUE
from fnd_profile_options p,
fnd_profile_option_values v,
fnd_profile_options_tl n
where p.profile_option_id = v.profile_option_id (+)
and p.profile_option_name = n.profile_option_name
and upper(n.user_profile_option_name) like upper('%&profile_name%')
/
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use
only.
17 [Queries for Apps DBA]
Database queries
Script to find the sid of the session you are logged in as
select distinct(sid) from v$mystat;
To see waiters
set linesize 1000
column waiting_session heading 'WAITING|SESSION'
column holding_session heading 'HOLDING|SESSION'
column lock_type format a15
column mode_held format a15
column mode_requested format a15
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use
only.
18 [Queries for Apps DBA]
select
waiting_session,
holding_session,
lock_type,
mode_held,
mode_requested,
lock_id1,
lock_id2
from
dba_waiters
/
This query will show all users that have active transactions and the rollback segment each
user is writing to:
col RBS format a15 trunc
col SID format 9999
col USER format a15 trunc
col COMMAND format a60 trunc
col status format a8 trunc
select r.name "RBS", s.sid, s.serial#, s.username "USER", t.status,
t.cr_get, t.phy_io, t.used_ublk, t.noundo,
substr(s.program, 1, 78) "COMMAND"
from v$session s, v$transaction t, v$rollname r
where t.addr = s.taddr
and t.xidusn = r.usn
order by t.cr_get, t.phy_io
/
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use
only.
19 [Queries for Apps DBA]
'Unknown') mode_requested
from dba_kgllock w, dba_kgllock h, v$session w1, v$session h1
where
(((h.kgllkmod != 0) and (h.kgllkmod != 1)
and ((h.kgllkreq = 0) or (h.kgllkreq = 1)))
and
(((w.kgllkmod = 0) or (w.kgllkmod= 1))
and ((w.kgllkreq != 0) and (w.kgllkreq != 1))))
and w.kgllktype = h.kgllktype
and w.kgllkhdl = h.kgllkhdl
and w.kgllkuse = w1.saddr
and h.kgllkuse = h1.saddr
/
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use
only.
20 [Queries for Apps DBA]
substr(to_char(l.session_id)||','||to_char(s.serial#),1,12) sid_ser,
substr(l.os_user_name||'/'||l.oracle_username,1,12) username,
l.process,
p.spid,
substr(o.owner||'.'||o.object_name,1,35) owner_object,
decode(l.locked_mode,
1,'No Lock',
2,'Row Share',
3,'Row Exclusive',
4,'Share',
5,'Share Row Excl',
6,'Exclusive',null) locked_mode,
substr(s.status,1,8) status
from
v$locked_object l,
all_objects o,
v$session s,
v$process p
where
l.object_id = o.object_id
and l.session_id = s.sid
and s.paddr = p.addr
and s.status != 'KILLED'
/
, s.osuser osuser
, sw.event event
, s.machine machine
, s.program program
from v$session_wait sw
, v$session s
, v$process p
where s.paddr = p.addr
and event not in ('pipe get','client message')
and sw.sid = s.sid
/
This script gives information about the user sessions locking a particular object
set linesize 1000
column program format a15
column object format a15
select substr(username||'('|| se0.sid||')',1,5) "User Session",
substr(owner,1,5) "Object Owner",
substr(object,1,15) "Object",
se0.sid,
substr(serial#,1,6) "Serial#",
substr(program,1,15) "Program",
logon_time "Logon Time",
process "Unix Process"
from v$access ac, v$session se0
where ac.sid = se0.sid
and Object = '&package_name'
order by logon_time,"Object Owner","Object"
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use
only.
22 [Queries for Apps DBA]
To see execution sql plan for the hash value. This could be different from what we get from
explain plan as execution condition like bind variable changes the thing
set linesize 9999
column QUERY format a999
set pages 250
set head off
set verify off
select id,lpad(' ',2*(depth-1)) || depth ||'.' || nvl(position,0) || ' '|| operation || ' '|| options
|| ' '|| object_name ||' '
||'cost= '|| to_char(cost)||' '|| optimizer "QUERY"
from v$sql_plan
where hash_value = &sql_hash_value
order by child_number,id
/
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use
only.
23 [Queries for Apps DBA]
Sql to show all the datafiles,redo logs and controlfiles in the database
ttitle off
break on file_type on report
This material is created by http://techgoeasy.com/ and is for your personal and non-commercial use
only.