Monday, 30 July 2012

oracle Apps DBA important scripts

The queries mentioned here are for my own purpose , please ensure and be careful before executing any DDL or delete script

1.Database Size or Size of Database

set linesize 200
set pagesize 200

SELECT /* + RULE */ df.tablespace_name "Tablespace",
df.bytes / (1024 * 1024) "Size (MB)",
SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
FROM dba_free_space fs,
(SELECT tablespace_name,SUM(bytes) bytes
FROM dba_data_files
GROUP BY tablespace_name) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY df.tablespace_name,df.bytes
UNION ALL
SELECT /* + RULE */ df.tablespace_name tspace,
fs.bytes / (1024 * 1024),
SUM(df.bytes_free) / (1024 * 1024),
Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 / fs.bytes), 1),
Round((SUM(fs.bytes) - df.bytes_free) * 100 / fs.bytes)
FROM dba_temp_files fs,
(SELECT tablespace_name,bytes_free,bytes_used
FROM v$temp_space_header
GROUP BY tablespace_name,bytes_free,bytes_used) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
ORDER BY 4 DESC;
2.How to Determine Which Manager Ran a Specific Concurrent Request?

col USER_CONCURRENT_QUEUE_NAME for a100
select b.USER_CONCURRENT_QUEUE_NAME from fnd_concurrent_processes a,
fnd_concurrent_queues_vl b, fnd_concurrent_requests c
where a.CONCURRENT_QUEUE_ID = b.CONCURRENT_QUEUE_ID
and a.CONCURRENT_PROCESS_ID = c.controlling_manager
and c.request_id = '&conc_reqid';

3.Concurrent manager status for a given sid?

col MODULE for a20
col OSUSER for a10
col USERNAME for a10
set num 10
col MACHINE for a20
set lines 200
col SCHEMANAME for a10
select 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';


4. 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';

5.To find sid,serial# for a given concurrent request id?

set lines 200
SELECT a.request_id, d.sid, d.serial# ,d.osuser,d.process , c.SPID ,d.inst_id
FROM apps.fnd_concurrent_requests a,
apps.fnd_concurrent_processes b,
gv$process c,
gv$session d
WHERE a.controlling_manager = b.concurrent_process_id
AND c.pid = b.oracle_process_id
AND b.session_id=d.audsid
AND a.request_id = &Request_ID
AND a.phase_code = 'R';


6.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;


7.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'
/

8. To find child requests

set lines 200
col USER_CONCURRENT_PROGRAM_NAME for a40
col PHASE_CODE for a10
col STATUS_CODE for a10
col COMPLETION_TEXT for a20

SELECT 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';


9. Cancelling Concurrent request :

update fnd_concurrent_requests
set status_code='D', phase_code='C'
where request_id=&req_id;

10. Kill sessions program wise

select 'ALTER SYSTEM KILL SESSION '''||sid||','||serial#||''' immediate;' from v$session where MODULE like '';


11 .Concurrent Request running by SID

SELECT a.request_id,
d.sid as Oracle_SID,
d.serial#,
d.osuser,
d.process,
c.SPID as OS_Process_ID
FROM apps.fnd_concurrent_requests a,
apps.fnd_concurrent_processes b,
gv$process c,
gv$session d
WHERE a.controlling_manager = b.concurrent_process_id
AND c.pid = b.oracle_process_id
AND b.session_id=d.audsid
AND d.sid = &SID;

12. Find out request id from Oracle_Process Id:

select REQUEST_ID,ORACLE_PROCESS_ID,OS_PROCESS_Id from fnd_concurrent_requests where ORACLE_PROCESS_ID='&a';


13. Oracle Concurrent Request Error Script (requests which were error ed 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 ctl
WHERE a.controlling_manager = b.concurrent_process_id
AND a.concurrent_program_id = c.concurrent_program_id
AND a.program_application_id = c.application_id
AND a.status_code = 'E'
AND a.phase_code = 'C'
AND actual_start_date > sysdate - 2
AND b.queue_application_id = q.application_id
AND b.concurrent_queue_id = q.concurrent_queue_id
AND ctl.concurrent_program_id = c.concurrent_program_id
AND ctl.LANGUAGE = 'US'
ORDER BY 5 DESC;


14. Request submitted by User

SELECT
user_concurrent_program_name,
request_date,
request_id,
phase_code,
status_code
FROM
fnd_concurrent_requests fcr,
fnd_concurrent_programs_tl fcp,
fnd_responsibility_tl fr,
fnd_user fu
WHERE
fcr.CONCURRENT_PROGRAM_ID = fcp.concurrent_program_id
and fcr.responsibility_id = fr.responsibility_id
and fcr.requested_by = fu.user_id
and user_name = '&user'
AND actual_start_date > sysdate - 1
ORDER BY REQUEST_DATE Asc;



15.Concurrent Program enable with trace

col User_Program_Name for a40
col Last_Updated_By for a30
col DESCRIPTION for a30
SELECT 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) DESCRIPTION
FROM APPS.FND_CONCURRENT_PROGRAMS_VL A, APPLSYS.FND_USER B
WHERE A.ENABLE_TRACE='Y'
AND A.LAST_UPDATED_BY=B.USER_ID;

Sunday, May 13, 2012


16.How to check Size of all tablespaces in the instance.


set linesize 200
set pagesize 200

SELECT /* + RULE */ df.tablespace_name "Tablespace",
df.bytes / (1024 * 1024) "Size (MB)",
SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
FROM dba_free_space fs,
(SELECT tablespace_name,SUM(bytes) bytes
FROM dba_data_files
GROUP BY tablespace_name) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY df.tablespace_name,df.bytes
UNION ALL
SELECT /* + RULE */ df.tablespace_name tspace,
fs.bytes / (1024 * 1024),
SUM(df.bytes_free) / (1024 * 1024),
Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 / fs.bytes), 1),
Round((SUM(fs.bytes) - df.bytes_free) * 100 / fs.bytes)
FROM dba_temp_files fs,
(SELECT tablespace_name,bytes_free,bytes_used
FROM v$temp_space_header
GROUP BY tablespace_name,bytes_free,bytes_used) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
ORDER BY 4 DESC;

Thursday, September 29, 2011



all important scripts

<< CM >>

select decode(count(*),0,' All Active',' WARNING: Please check RUNNING vs MAX Process on CCM!')
from fnd_concurrent_queues
where running_processes <> max_processes
/

<< Running >>

select
/*+ choose */
count(*)
from
fnd_concurrent_requests fcr,
fnd_concurrent_programs c,
fnd_conc_req_summary_v fcrv
where
fcr.concurrent_program_id = c.concurrent_program_id
and fcr.program_application_id = c.application_id
and fcr.CONCURRENT_PROGRAM_ID = fcrv.CONCURRENT_PROGRAM_ID
and fcr.REQUEST_ID = fcrv.REQUEST_ID
and fcr.phase_code in ('R','T')
/


------------
List
------------


select
/*+ choose */
U.USER_NAME User_name,
fcr.request_id request_id,
to_char(round((nvl(fcr.actual_completion_date,sysdate)-fcr.actual_start_date)*1440)) Time,
c.concurrent_program_name||' - ' ||
substr(fcrv.program,1,55) PROGRAM,
fcr.CONCURRENT_PROGRAM_ID Program_id,
fcr.PARENT_REQUEST_ID Parent_id
from
fnd_concurrent_requests fcr,
fnd_concurrent_programs c,
fnd_conc_req_summary_v fcrv,
fnd_user U
where
fcr.concurrent_program_id = c.concurrent_program_id
and fcr.program_application_id = c.application_id
and fcr.CONCURRENT_PROGRAM_ID = fcrv.CONCURRENT_PROGRAM_ID
and fcr.REQUEST_ID = fcrv.REQUEST_ID
and fcr.phase_code in ('R','T')
and fcr.requested_by = U.user_id
order by request_id asc
/



<< Pending >>

select
/*+ choose */
count(*)
from
fnd_concurrent_requests fcr,
fnd_concurrent_programs c,
fnd_conc_req_summary_v fcrv
where
fcr.concurrent_program_id = c.concurrent_program_id
and fcr.program_application_id = c.application_id
and fcr.CONCURRENT_PROGRAM_ID = fcrv.CONCURRENT_PROGRAM_ID
and fcr.REQUEST_ID = fcrv.REQUEST_ID
and fcrv.REQUESTED_START_DATE < sysdate+10/1440
and fcr.phase_code in ('P')
and fcr.HOLD_FLAG != 'Y'
/

------------
List
------------

select
/*+ choose */
U.USER_NAME User_name,
fcr.request_id request_id,
to_char(round((nvl(fcr.actual_completion_date,sysdate)-fcr.actual_start_date)*1440)) Time,
c.concurrent_program_name||' - ' ||
substr(fcrv.program,1,45) PROGRAM,
fcr.CONCURRENT_PROGRAM_ID Program_id,
fcr.PARENT_REQUEST_ID Parent_id,
to_char(fcrv.REQUESTED_START_DATE,'DD-MON-RR HH24:MI') Scheduled,
DECODE(fcr.phase_code ,
'C','Completed',
'I','Inactive',
'P','Pending',
'R','Running') || ' - ' ||
DECODE(fcr.status_code,
'A','Waiting',
'B','Resuming',
'C','Normal',
'D','Cancelled',
'E','Error',
'G','Warning',
'H','On Hold',
'I','Normal',
'M','No Manager',
'P','Scheduled',
'Q','Standby',
'R','Normal',
'S','Suspended',
'T','Terminating',
'U','Disabled',
'W','Paused',
'X','Terminated',
'Z',' Waiting') Status
from
fnd_concurrent_requests fcr,
fnd_concurrent_programs c,
fnd_conc_req_summary_v fcrv,
fnd_user U
where
fcr.concurrent_program_id = c.concurrent_program_id
and fcr.program_application_id = c.application_id
and fcr.CONCURRENT_PROGRAM_ID = fcrv.CONCURRENT_PROGRAM_ID
and fcr.REQUEST_ID = fcrv.REQUEST_ID
and fcrv.REQUESTED_START_DATE < sysdate+10/1440
and fcr.phase_code in ('P')
and fcr.HOLD_FLAG != 'Y'
and fcr.requested_by = U.user_id
order by 1, 2 asc
/



<< Long Running >>

select
count(*)
from fnd_conc_req_summary_v fcrv,
fnd_concurrent_requests fcr
where fcrv.phase_code in ('R','I')
and round(((sysdate - fcrv.actual_start_date)*1440),2) > 60
and fcrv.request_id = fcr.request_id
and fcrv.program not in ('Notification Mailer')
/

------------
List
------------


select substr(fcrv.request_id,1,7)REQUEST,
lpad(decode(fcrv.phase_code,'P','Pending','R','Running','I','Inactive','Completed'),8,' ')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,
rpad(substr(fcrv.program,1,65),65,' ')PROGRAM,
lpad(substr(fcrv.requestor,1,9),9,' ')REQUESTOR,
rpad(to_char(fcrv.actual_start_date,'MM/DD/RR HH24:MI:SS AM'),20,' ')START_TIME,
lpad(round(((sysdate - fcrv.actual_start_date)*1440),2),11,' ')RUN_TIME
--lpad(substr(fcr.oracle_process_id,1,7),7,' ')OS_PID
from fnd_conc_req_summary_v fcrv,
fnd_concurrent_requests fcr
where fcrv.phase_code in ('R','I')
and round(((sysdate - fcrv.actual_start_date)*1440),2) > 120
and fcrv.request_id = fcr.request_id
and fcrv.program not in ('Notification Mailer')
order by RUN_TIME desc
/


<< Sessions Forms >>

select count(*) from fnd_form_sessions_v
/

<< Sessions SQL >>
select
count(*)
from
gv$session a,
v$dispatcher b,
v$circuit c,
v$process d
where
a.saddr = c.saddr(+)
and a.server is not null
and b.paddr(+) = c.dispatcher
and a.paddr(+) = d.addr
and ( UPPER(a.program) like '%SQL%'
or UPPER(a.program) like '%TOAD%'
or a.module like '%SQL%'
or a.module like 'T.O.A.D%'
or a.module like 'TOAD%'
)
/


<< Sessions Web >>

SELECT
count(*)
FROM v$process p,
gv$session s
WHERE p.addr = s.paddr
and s.program = 'JDBC Thin Client'
/



<< Global Locks >>

select count(*)
from gv$lock a
where a.id1 in ( select id1 from gv$lock where request <> 0 )
/

------------
List
------------

select a.inst_id, a.sid, a.type, a.id1, a.id2,
decode(a.lmode, 0, 'NONE', 1, 'NULL', 2, 'ROW SHARE',
3, 'ROW EXCLUSIVE', 4, 'SHARE', 5, 'SHARE ROW EXCLUSIVE',
6, 'EXCLUSIVE', '?'),
decode(a.request, 0, 'NONE', 1, 'NULL', 2, 'ROW SHARE',
3, 'ROW EXCLUSIVE', 4, 'SHARE', 5, 'SHARE ROW EXCLUSIVE',
6, 'EXCLUSIVE', '?'),
a.block
from gv$lock a
where a.id1 in ( select id1 from gv$lock where request <> 0 )
order by a.id1, a.request, a.sid
/


<< Memory Hogs > 512MB >>
select s.inst_id, s.sid, name, round(value/1024/1024) Mem_in_mb
from gv$sesstat s, v$statname n, gv$session p
where n.statistic# = s.statistic#
and s.inst_id = p.inst_id
and s.sid = p.sid
and name like '%pga memory%'
and value > 1*1024*1024*512
/

------------
List
------------
select s.inst_id, s.sid, name, round(value/1024/1024) Mem_in_mb
from gv$sesstat s, v$statname n, gv$session p
where n.statistic# = s.statistic#
and s.inst_id = p.inst_id
and s.sid = p.sid
and name like '%pga memory%'
and value > 1*1024*1024*512
/



<< Top 10 SQL >>

select * from
(select sql_text,
cpu_time/1000000 cpu_time,
elapsed_time/1000000 elapsed_time,
disk_reads,
buffer_gets,
rows_processed
from v$sqlarea
order by cpu_time desc, disk_reads desc
)
where rownum < 11
/
select a.value, s.username, s.sid, s.serial#
from v$sesstat a, v$statname b, v$session s
where a.statistic# = b.statistic# and s.sid=a.sid
and b.name = 'opened cursors current';


open_cursors_by_users.txt

--total cursors open, by username & machine
select sum(a.value) total_cur, avg(a.value) avg_cur, max(a.value) max_cur,
s.username, s.machine
from v$sesstat a, v$statname b, v$session s
where a.statistic# = b.statistic# and s.sid=a.sid
and b.name = 'opened cursors current'
group by s.username, s.machine
order by 1 desc;




check tablespace in gb.txt

set linesize 200
set pagesize 200

SELECT /* + RULE */ df.tablespace_name "Tablespace",
df.bytes / (1024 * 1024) "Size (MB)",
SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
FROM dba_free_space fs,
(SELECT tablespace_name,SUM(bytes) bytes
FROM dba_data_files
GROUP BY tablespace_name) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY df.tablespace_name,df.bytes
UNION ALL
SELECT /* + RULE */ df.tablespace_name tspace,
fs.bytes / (1024 * 1024),
SUM(df.bytes_free) / (1024 * 1024),
Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 / fs.bytes), 1),
Round((SUM(fs.bytes) - df.bytes_free) * 100 / fs.bytes)
FROM dba_temp_files fs,
(SELECT tablespace_name,bytes_free,bytes_used
FROM v$temp_space_header
GROUP BY tablespace_name,bytes_free,bytes_used) df
WHERE fs.tablespace_name (+) = df.tablespace_name
GROUP BY df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
ORDER BY 4 DESC;

blocking_sessions.txt

set lines 300;
set echo off;
set head off;
set pages 60;
set feed off;
spool &1
select s1.username || '@' || s1.machine
|| ' ( SID=' || s1.sid || ' ) is blocking '
|| s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_status
from v$lock l1, v$session s1, v$lock l2, v$session s2
where s1.sid=l1.sid and s2.sid=l2.sid
and l1.BLOCK=1 and l2.request > 0
and l1.id1 = l2.id1
and l2.id2 = l2.id2;
spool off;
exit;



select s1.sid||','||s1.serial# Blocker ,sql1.sql_text Blocking_sql,
s2.sid||','||s2.serial# Waiting ,sql2.sql_text Waiting_sql
from v$lock l1, v$session s1, v$lock l2, v$session s2,
v$sqltext_with_newlines sql1,v$sqltext_with_newlines sql2
where s1.sid=l1.sid and s2.sid=l2.sid
and sql1.hash_value=s1.sql_hash_value
and sql1.address=s1.sql_address
and sql2.hash_value=s2.sql_hash_value
and sql2.address=s2.sql_address
and l1.BLOCK=1 and l2.request > 0
and l1.id1 = l2.id1
and l2.id2 = l2.id2;


concurrent running status.txt

set echo off
set linesize 130
set serveroutput on size 50000
set feed off
set veri off
DECLARE
running_count NUMBER := 0;
pending_count NUMBER := 0;
crm_pend_count NUMBER := 0;
--get the list of all conc managers and max worker and running workers
CURSOR conc_que IS
SELECT concurrent_queue_id,
concurrent_queue_name,
user_concurrent_queue_name,
max_processes,
running_processes
FROM apps.fnd_concurrent_queues_vl
WHERE enabled_flag='Y' and
concurrent_queue_name not like 'XDP%' and
concurrent_queue_name not like 'IEU%' and
concurrent_queue_name not in ('ARTAXMGR','PASMGR') ;
BEGIN
DBMS_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_que
LOOP
--for each manager get the number of pending and running requests in each queue
SELECT /*+ RULE */ nvl(sum(decode(phase_code, 'R', 1, 0)), 0),
nvl(sum(decode(phase_code, 'P', 1, 0)), 0)
INTO running_count, pending_count
FROM fnd_concurrent_worker_requests
WHERE
requested_start_date <= sysdate
and concurrent_queue_id = i.concurrent_queue_id
AND hold_flag != 'Y';
--for each manager get the list of requests pending due to conflicts in each manager
SELECT /*+ RULE */ count(1)
INTO crm_pend_count
FROM apps.fnd_concurrent_worker_requests a
WHERE concurrent_queue_id = 4
AND hold_flag != 'Y'
AND requested_start_date <= sysdate
AND exists (
SELECT 'x'
FROM apps.fnd_concurrent_worker_requests b
WHERE a.request_id=b.request_id
and concurrent_queue_id = i.concurrent_queue_id
AND 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 on
set echo on


forms_sessions_by_node.txt

set lines 300;
col RESPONSIBILITY_NAME for a30;
col USER_FORM_NAME for a30;
col machine for a15;
col user_name for a20;
select to_char(sysdate,'DD-MM-YY HH24:MI:SS') from dual;
select
count(user_name)
,Machine
from
apps.fnd_form_sessions_v a, gv$session b
where
a.sid=b.sid and
a.serial# = b.serial#
group by machine;

Wednesday, 25 May 2011

How to Create a Database User

SQL>  select GRANTEE,GRANTED_ROLE,ADMIN_OPTION,DEFAULT_ROLE from dba_role_privs where GRANTEE ='JOHNSS1';
GRANTEE                        GRANTED_ROLE                   ADM DEF
------------------------------ ------------------------------ --- ---
JOHNSS1                        RPG_READ_ACCESS                NO  YES
SQL> select DEFAULT_TABLESPACE,TEMPORARY_TABLESPACE from dba_users where username = 'JOHNSS1';
DEFAULT_TABLESPACE             TEMPORARY_TABLESPACE
------------------------------ ------------------------------
TOOLS                          TEMP
SQL> CREATE USER SELVAJ IDENTIFIED BY ****
  2  DEFAULT TABLESPACE TOOLS
  3  TEMPORARY TABLESPACE temp
  4  ;
User created.
SQL> grant RPG_READ_ACCESS to SELVAJ;
Grant succeeded.
SQL> select GRANTEE,GRANTED_ROLE,ADMIN_OPTION,DEFAULT_ROLE from dba_role_privs where GRANTEE ='SELVAJ';
GRANTEE                        GRANTED_ROLE                   ADM DEF
------------------------------ ------------------------------ --- ---
SELVAJ                         RPG_READ_ACCESS                NO  YES
SQL> conn SELVAJ/*****



Wednesday, 11 May 2011

How to enable a trace for a concurrent program

Login as Sysadmin -> System Administrator -> Concurrent : Program -> Define
Press F11 -> Enter the COncurrent Program Name (Eg. Active Users) -> Press Ctrl + F11
Enable the check box “Enable Trace” above “Copy To” button.
Click on Save.
Close the window.
Select Requests -> Run
Submit the concurrent request.
After completion or during execution of the request, you should see a trace file generated on the database server under udump directory.
SQL to identify the trace file
select oracle_process_id from fnd_concurrent_requests where request_id=[request_id];
DB Node
cd $ORACLE_HOME/admin/[SID]_[hostname]/udump
ls -latr *[oracle_process_id]*.*
P.S: Dont forget to disable the trace :-)

Saturday, 23 April 2011

how to drop a tablespace

DROP TABLESPACE <tablespace name> INCLUDING CONTENTS AND DATAFILES;

If you don’t specify “AND DATAFILES”, Oracle will not drop the physical datafile after the DROP TABLESPACE command, but you can always delete the files from operating system shell (If the data files are locked, restart the server).
But always perform a backup of the database, as the “DROP TABLESPACE” command is irreversible. It’s also a good practice to check and identify how many datafiles a tablespace actually has before performing the drop action in order to avoid mistake.

SQL> select name from v$database;
NAME
---------
PNDW
SQL>
SQL>
SQL> select STATUS from v$datafile where NAME like '%xxtne%';
STATUS
-------
OFFLINE
OFFLINE
OFFLINE
OFFLINE
SQL> select TABLESPACE_NAME,STATUS from dba_tablespaces where tablespace_name in ('XXTNED','XXTNEX');
TABLESPACE_NAME                STATUS
------------------------------ ---------
XXTNED                         OFFLINE
XXTNEX                         OFFLINE

SQL> select file_name from dba_data_files where tablespace_name in ('XXTNED','XXTNEX');
FILE_NAME
--------------------------------------------------------------------------------
/aa_gen_dvd/oradata02/pndw/xxtned01.dbf
/aa_gen_dvd/oradata02/pndw/xxtnex01.dbf
/aa_gen_dvd/oradata02/pndw/xxtned02.dbf
/aa_gen_dvd/oradata02/pndw/xxtnex02.dbf
pndw$bdf /aa_gen_dvd/oradata02/
Filesystem          kbytes    used   avail %used Mounted on
/dev/vgaa_gen_dvd/lvol4
                   131072000 123009269 7581899   94% /aa_gen_dvd/oradata02

SQL> select name from v$database;
NAME
---------
PNDW
SQL> DROP TABLESPACE XXTNED INCLUDING CONTENTS AND DATAFILES;
Tablespace dropped.
SQL>
SQL>
SQL> DROP TABLESPACE XXTNEX INCLUDING CONTENTS AND DATAFILES;
Tablespace dropped.
SQL>
SQL> select file_name from dba_data_files where tablespace_name in ('XXTNED','XXTNEX');
no rows selected
SQL> select TABLESPACE_NAME,STATUS from dba_tablespaces where tablespace_name in ('XXTNED','XXTNEX');
no rows selected
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
pndw$bdf /aa_gen_dvd/oradata02/
Filesystem          kbytes    used   avail %used Mounted on
/dev/vgaa_gen_dvd/lvol4
                   131072000 102529205 26781960   79% /aa_gen_dvd/oradata02

Wednesday, 20 April 2011

find the details of concurrent requests from request id

set linesize 900
column RESPONSIBILITY_NAME format a30
column USER_CONCURRENT_PROGRAM_NAME format a30
column MACHINE  format a10
column REQUESTOR format a15

select cmp.USER_CONCURRENT_PROGRAM_NAME ,cm.request_id,
(select user_name from apps.fnd_user where USER_ID =cm.requested_by) Requestor, PARENT_REQUEST_ID,t.USED_UREC,t.USED_UBLK,cm.phase_code,
cm.status_code,s.sid,s.serial#,s.saddr,s.username,s.status, s.OSUSER,s.PROCESS,
s.MODULE,s.ACTION,fr.RESPONSIBILITY_NAME
from v$transaction t,v$session s,apps.FND_CONCURRENT_REQUESTS cm,
apps.FND_RESPONSIBILITY_VL fr,
apps.FND_CONCURRENT_PROGRAMS_VL cmp
where t.addr(+)=s.taddr and s.process(+)=cm.os_process_id
AND fr.RESPONSIBILITY_ID= cm.RESPONSIBILITY_ID
AND cmp.CONCURRENT_PROGRAM_ID=cm.CONCURRENT_PROGRAM_ID
and cm.request_id=&reqid
/

Tuesday, 5 April 2011

R12

In this post I am going to cover R12 architecture. Discernible change from its predecessors is INST_TOP.

R12 file system has come up with new model - Code, Data, Configurations are segregated nicely to have easy maintenance, to avert NFS mount issues on shared appltier configuration systems. Autoconfig will not write anything in appltop, commontop area in R12. All instance specific configurations, log files are written in INST_TOP area. Instance Home provides the ability to share Applications and technology stack code among multiple instances. I have highlighted the INST_TOP in the box. In the forthcoming posts I will clearly explain the in depth of INST_TOP(As a DBA you will spend much time in INST_TOP area when you comes to application tier node management ( e.g checking logs, starting/stopping services, ssl certificates management, CONTEXT_FILE modification etc.)

Techstack Components:

DB_TIER:
10.2.0.2 RDBMS ORACLE_HOME

APPL-TIER

10.1.2 C ORACLE_HOME / FORMS ORACLE_HOME (8.0.6 ORACLE HOME equivalence)
10.1.3 Java ORACLE_HOME/OC4J ORACLE_HOME (iAS ORACLE_HOME equivalence)

Concurrent Manager

set verify off
set lines 256
set trims ON
set pages 60
col concurrent_queue_id format 99999 heading "QUEUE Id"
col concurrent_queue_name format a20 trunc heading "QUEUE Code"
col user_concurrent_queue_name format a30 trunc heading "Concurrent Queue Name"
col max_processes format 999 heading "Max"
col running_processes format 999 heading "Act"
col running format 999 heading "Run"
col target_node format a15 heading "Node"
col status format a12 trunc heading "Status"
col run format 9999 heading 'Run'
col pend format 9999 heading 'Pending'
col cmgr_program FOR a65;
SELECT 'Instance : '
    ||NAME instance_name
FROM   v$database;

Prompt ===========================
Prompt concurrent manager status
Prompt ===========================
SELECT q.concurrent_queue_id,
      q.concurrent_queue_name,
      q.user_concurrent_queue_name,
      q.target_node,
      q.max_processes,
      q.running_processes,
      running.run                               running,
      pending.pend,
      Decode(q.control_code, 'D', 'Deactivating',
                             'E', 'Deactivated',
                             'N', 'Node unavai',
                             'A', 'Activating',
                             'X', 'Terminated',
                             'T', 'Terminating',
                             'V', 'Verifying',
                             'O', 'Suspending',
                             'P', 'Suspended',
                             'Q', 'Resuming',
                             'R', 'Restarting') status
FROM   (SELECT concurrent_queue_name,
              COUNT(phase_code) run
       FROM   fnd_concurrent_worker_requests
       WHERE  phase_code = 'R'
              AND hold_flag != 'Y'
              AND requested_start_date <= SYSDATE
       GROUP  BY concurrent_queue_name) running,
      (SELECT concurrent_queue_name,
              COUNT(phase_code) pend
       FROM   fnd_concurrent_worker_requests
       WHERE  phase_code = 'P'
              AND hold_flag != 'Y'
              AND requested_start_date <= SYSDATE
       GROUP  BY concurrent_queue_name) pending,
      apps.fnd_concurrent_queues_vl q
WHERE  q.concurrent_queue_name = running.concurrent_queue_name(+)
      AND q.concurrent_queue_name = pending.concurrent_queue_name(+)
      AND q.enabled_flag = 'Y'
ORDER BY Decode(q.application_id, 0, Decode(q.concurrent_queue_id, 1, 1,4, 2)),
         Sign(q.max_processes) DESC,
         q.concurrent_queue_name,
         q.application_id;




Monday, 21 March 2011

find and remove files older then 30 days

find /eb_rao0_p/applmgr/pnoltpcomn/admin/log/pnoltp_auxpap02/f60webmx_dump*  -mtime +30 -exec rm  {} \;


:find /eb_rao0_p/applmgr/pnoltpcomn/admin/log/pnoltp_auxpap02/*.log  -mtime +30 -exec rm  {} \;


 

Sunday, 13 March 2011

Usefull daily activities commands

alter system kill session '2405,2664';
find / -name "*.system.log"
$Header bomstrc.odf 115.19.115102.3 2005/12/14 21:19:47 rfarook ship
$ find ./ -type l -exec ls -ltr {} \; | grep fndcpesr

If  file  A has control characters and then want to remove follow these steps.
dos2ux  A > B
mv B A
A  is now clean of control Characters

rm `ls -lrt | grep "Dec 26" | awk '{print $9}'`  -- /eb_rda0_p/applcsf
find . -name "*.req" -mtime +80 -exec rm '{}' \; -- keep 80 days and remove all b4 that
select running_processes from fnd_concurrent_queues where concurrent_queue_name = 'WFMLRSVC';---check workflow mailer

ddw7$find . -mtime +10 -exec rm -rf {} \;
ddw7$find . -mtime +10 -exec ls -lrt {} \;
find /tmp -name "Acro*" -mtime +15 -exec rm –f  {} \;

ls -l *.log|sort +4 -nr | more

vmstat 1 10

@usrsql_sid.sql

select l1.sid,v1.serial#, ' IS BLOCKING ',l2.sid from gv$lock l1,gv$lock l2,v$session v1 where v1.sid = l1.sid and  l1.block =1 and l2.request > 0 and
l1.id1=l2.id1 and l1.id2=l2.id2;

SELECT s.sid, p.spid, 'kill -9 '||p.spid FROM v$session s, v$process p WHERE s.paddr=p.addr(+) AND s.sid=3749

alter tablespace IEXX add datafile '/eb_rdo0_p/oradata/pnoltpdata/iexx104.dbf' size 1000m;
tkprof pnoltp_ora_27707_CSISCHED_CR302445386.trc pnoltp_ora_27707_CSISCHED_CR302445386.txt sys=no  sort='(prsela,exeela,fchela)' explain=apps/p0rSche

dba SELECT 'alter system kill session ''' || sid || ',' || serial# || ''';'
> FROM v$session
> WHERE status LIKE 'INACTIVE' AND MODULE LIKE 'JDBC Thin Client'
> AND username NOT LIKE 'APPLSYSPUB' AND TRUNC(logon_time) <
> TRUNC(SYSDATE)ORDER BY logon_time; 
>
>
>
>
> /******************** Blocking Session *******************************/
SELECT * FROM dba_locks WHERE blocking_others='Blocking'
>

SELECT * FROM v$locked_object WHERE object_id=2392
/******************* Holder(1)& Waiters(0) **************************/
>
SELECT DECODE(request,0,'Holder: ','Waiter: ')|| sid sess, id1, id2,lmode,request, TYPE FROM V$LOCK WHERE (id1, id2, TYPE) IN (SELECT id1, id2, TYPE FROM V$LOCK WHERE request>0) ORDER BY id1, request
>
>
> /******************* Latch Count *************************************/
SELECT event, COUNT(1) FROM v$session_wait WHERE event IN ('latch free','enqueue','library cache lock','library cache load lock','library cache pin') GROUP BY event HAVING COUNT(1) > 2 ORDER BY event
>
> /******************** Latching Session *******************************/
> SELECT event, w.sid, s.sql_hash_value, s.username, seq#, wait_time,
> seconds_in_wait,
> DECODE( p1text, NULL, NULL, p1text || ' = ' || p1 ) ||
> DECODE( p2text, NULL, NULL, ', ' || p2text || ' = ' || p2 ) ||
> DECODE( p3text, NULL, NULL, ', ' || p3text || ' = ' || p3 )
> parameters,
> DECODE( s.action, 'Concurrent Request', 'CM/' || s.MODULE, s.MODULE
> ) program_name
> FROM v$session s, v$session_wait w
> WHERE event NOT IN ( 'pmon timer','rdbms ipc message','smon timer','WMON
> goes to sleep', 'pipe get', 'pipe put',-- 'Null event',
> 'SQL*Net message from client','client message','slave
> wait','queue messages', 'wakeup time manager', 'i/o slave wait' )
> AND w.sid = s.sid -- and event in ('latch free','enqueue','library
> cache lock','library cache load lock','library cache pin')
> AND event = 'enqueue'
> ORDER BY event, p1, p2;
>
> /******************** Running Sessoin *******************************/
SELECT /*+ choose */ s.status "Status", si.sid, s.MODULE "Module",s.username "DB User", s.osuser "OS User", s.machine "Machine",s.TYPE "Type",s.client_info "Client Info", s.server "Server", s.terminal "Terminal", s.program "Program", p.program "O.S. Program", lockwait "Lock Wait", s.process "Process", p.pid, s.audsid,s.action FROM v$session s, v$process p, sys.V_$SESS_IO si WHERE s.paddr = p.addr(+) AND si.sid(+) = s.sid AND s.sid = 2801 AND (s.username IS NOT NULL) ORDER BY 1 ASC,6 DESC
 /******************** Running Query *******************************/
SELECT * FROM v$sql WHERE hash_value=:hv
>
 select * from v$session where sid=4037

>
> /******************** Killing UNIX Sessoin *******************************/
SELECT s.sid, p.spid, 'kill -9 '||p.spid FROM v$session s, v$process p WHERE s.paddr=p.addr(+) AND s.sid=2244
>
> /********* Killing Long Running FRONT END Sessoin (Executed in each 15
> min)*************/
> SELECT sid, MODULE, status, last_call_et "SECONDS RUNNING",'kill -9
> '||p.spid
> FROM v$session s, v$process p WHERE s.paddr = p.addr AND s.last_call_et >=
> 300
> AND s.status <> 'INACTIVE' AND MODULE IN
> ('CSCCCCRC','HTGWRK','XXHTCSCCCCRC')
> --'JDBC Thin Client','FNDSCSGN') -- include this also to kill all the front
> end user's session.
>
> /******************** Killing stray database sessions
> **********************/
> SELECT 'alter system kill session ''' || sid || ',' || serial# || ''';'
> FROM v$session
> WHERE status LIKE 'INACTIVE' AND MODULE LIKE 'JDBC Thin Client'
> AND username NOT LIKE 'APPLSYSPUB' AND TRUNC(logon_time) <
> TRUNC(SYSDATE)ORDER BY logon_time;
>
>
> /**************** Monitoring/Cleaning stray Oracle processes ************/
> -- OS processes created by Oracle and which does not has corresponding
> oracle sessions
> -- Kill process containing(LOCAL=NO) and have date older than the current
> date
SELECT 'ps -fp '||spid,'kill -9 '||spid FROM v$process WHERE NOT EXISTS
 (SELECT 1 FROM v$session WHERE paddr = addr);
>
> /**************** Library Cache Lock/Pins ******************/
> SELECT /*+ ordered */ w1.sid waiting_session, p.spid, h1.sid
> holding_session, p1.spid,w.kgllktype lock_or_pin, w.kgllkhdl address,
> DECODE(h.kgllkmod, 0, 'None', 1, 'Null', 2, 'Share', 3, 'Exclusive',
> 'Unknown') mode_held,
> DECODE(w.kgllkreq, 0, 'None', 1, 'Null', 2, 'Share', 3, 'Exclusive',
> 'Unknown') mode_requested
> FROM DBA_KGLLOCK w, DBA_KGLLOCK h, v$session w1, v$session h1, v$process
> p, v$process p1
> 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 AND p.addr = w1.paddr AND
> p1.addr = h1.paddr
>
> SELECT sid, MODULE, status, sql_hash_value FROM v$session WHERE sid=&sid;
>
SELECT DISTINCT sql_text FROM v$sql WHERE hash_value=&hv;
>
> /***************** Shared Pool free size ********************/
SELECT * FROM v$parameter WHERE name LIKE 'shared%'
>
> SELECT pool,name,bytes/1024/1024 "FREE MB" FROM v$sgastat WHERE pool LIKE
> '%shared pool%' AND name LIKE '%free%'
>
> /***************** User wise session check ********************/
 SELECT username, status, COUNT(1) FROM v$session GROUP BY username, status ORDER BY 1
>
> /***************** Gather Stats Monitoring *******************/
> SELECT sid, opname, message, ROUND(((totalwork-sofar)/totalwork),4)*100 "%
> PENDING", time_remaining,
> start_time, username, sql_hash_value, serial# FROM v$session_longops WHERE
> time_remaining >0
>
> /***************** Top most executing queries ****************/
SELECT COUNT(*), SUM(executions) "TotExecs", MODULE,SUBSTR(sql_text,1,100)"SQL" FROM v$sqlarea WHERE executions < 5 GROUP BY SUBSTR(sql_text,1,100),MODULE HAVING COUNT(*) > 30 ORDER BY 1 DESC;
>
>
>
> SELECT * vrom v$process WHERE spid = :spid;
>
> SELECT * FROM V$session WHERE paddr = :addr;
>
>
>
> SELECT 'kill -9 ' ||p.spid
> FROM v$session s, v$process p, sys.V_$SESS_IO si
> WHERE s.paddr = p.addr(+) AND si.sid(+) = s.sid AND
> --s.username IN ('ORASSO_PUBLIC')
> s.username IN ('PORTAL_PUBLIC', 'ORASSO_PUBLIC','PORTAL')
> --('PORTAL_PUBLIC', 'ORASSO_PUBLIC')
> --s.username IN ('PORTAL_PUBLIC')
> --s.username IN ('PORTAL')
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> TO FIND OUT AUDIT++++++++++++++++++++++++++++++++++++++++++++++++
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
> SELECT
> DECODE(NVL(alt,'-/-'),'-/-',NULL,CHR(0)||CHR(47)||CHR(0),NULL,'noaudit
> alter on '||owner||'.'||object_name||';') alt_stmpt
> ,DECODE(NVL(aud,'-/-'),'-/-',NULL,CHR(0)||CHR(47)||CHR(0),NULL,'noaudit
> audit on '||owner||'.'||object_name||';') aud_stmt
> ,DECODE(NVL(com,'-/-'),'-/-',NULL,CHR(0)||CHR(47)||CHR(0),NULL,'noaudit
> comment on '||owner||'.'||object_name||';') com_stmt
> ,DECODE(NVL(del,'-/-'),'-/-',NULL,CHR(0)||CHR(47)||CHR(0),NULL,'noaudit
> delete on '||owner||'.'||object_name||';') del_stmt
> ,DECODE(NVL(gra,'-/-'),'-/-',NULL,CHR(0)||CHR(47)||CHR(0),NULL,'noaudit
> grant on '||owner||'.'||object_name||';') gra_stmt
> ,DECODE(NVL(ind,'-/-'),'-/-',NULL,CHR(0)||CHR(47)||CHR(0),NULL,'noaudit
> index on '||owner||'.'||object_name||';') ind_stmt
> ,DECODE(NVL(ins,'-/-'),'-/-',NULL,CHR(0)||CHR(47)||CHR(0),NULL,'noaudit
> insert on '||owner||'.'||object_name||';') ins_stmt
> ,DECODE(NVL(loc,'-/-'),'-/-',NULL,CHR(0)||CHR(47)||CHR(0),NULL,'noaudit
> lock on '||owner||'.'||object_name||';') loc_stmt
> ,DECODE(NVL(ren,'-/-'),'-/-',NULL,CHR(0)||CHR(47)||CHR(0),NULL,'noaudit
> rename on '||owner||'.'||object_name||';') ren_stmt
> ,DECODE(NVL(sel,'-/-'),'-/-',NULL,CHR(0)||CHR(47)||CHR(0),NULL,'noaudit
> select on '||owner||'.'||object_name||';') sel_stmt
> ,DECODE(NVL(upd,'-/-'),'-/-',NULL,CHR(0)||CHR(47)||CHR(0),NULL,'noaudit
> update on '||owner||'.'||object_name||';') upd_stmt
> ,DECODE(NVL(REF,'-/-'),'-/-',NULL,CHR(0)||CHR(47)||CHR(0),NULL,'noaudit
> reference on '||owner||'.'||object_name||';') ref_stmt
> ,DECODE(NVL(exe,'-/-'),'-/-',NULL,CHR(0)||CHR(47)||CHR(0),NULL,'noaudit
> execute on '||owner||'.'||object_name||';') exe_stmt
> ,DECODE(NVL(cre,'-/-'),'-/-',NULL,CHR(0)||CHR(47)||CHR(0),NULL,'noaudit
> create on '||owner||'.'||object_name||';') cre_stmt
> ,DECODE(NVL(rea,'-/-'),'-/-',NULL,CHR(0)||CHR(47)||CHR(0),NULL,'noaudit
> read on '||owner||'.'||object_name||';') rea_stmt
> ,DECODE(NVL(wri,'-/-'),'-/-',NULL,CHR(0)||CHR(47)||CHR(0),NULL,'noaudit
> write on '||owner||'.'||object_name||';') wri_stmt
> FROM DBA_OBJ_AUDIT_OPTS
> WHERE (ALT <> '-/-'
> OR AUD <> '-/-'
> OR COM <> '-/-'
> OR DEL <> '-/-'
> OR GRA <> '-/-'
> OR IND <> '-/-'
> OR INS <> '-/-'
> OR LOC <> '-/-'
> OR REN <> '-/-'
> OR SEL <> '-/-'
> OR UPD <> '-/-'
> OR REF <> '-/-'
> OR EXE <> '-/-'
> OR CRE <> '-/-'
> OR REA <> '-/-'
> OR WRI <> '-/-' )
> ORDER BY 3, owner, object_type, object_name
>
> USER growth month BY month -
> SELECT TO_CHAR(TRUNC(creation_date),'Mon-yy') "Month", COUNT(*) "No. Of
> users created"
> FROM fnd_user WHERE TRUNC(creation_date) >= '01-Jan-05' GROUP BY
> TO_CHAR(TRUNC(creation_date),'Mon-yy')
> ORDER BY TO_DATE(TO_CHAR(TRUNC(creation_date),'Mon-yy'),'Mon-yy');
>
> USER growth weekly-
> SELECT TO_CHAR(TRUNC(creation_date),'Mon-yy')
> "Month",TO_CHAR(TRUNC(creation_date),'W') "Week", COUNT(*) "No. Of users
> created"
> FROM fnd_user WHERE TRUNC(creation_date) >= '01-Jan-06'
> GROUP BY TO_CHAR(TRUNC(creation_date),'Mon-yy'),
> TO_CHAR(TRUNC(creation_date),'W')
> ORDER BY TO_DATE(TO_CHAR(TRUNC(creation_date),'Mon-yy'),'Mon-yy'),
> TO_CHAR(TRUNC(creation_date),'W');
>
>
> SPACE growth month BY month -
> SELECT b.name,TO_CHAR(a.creation_time,'Mon-yy')
> "Month",SUM(a.bytes/(1024*1024)) "Size of datafile added"
> FROM v$datafile a, v$tablespace b WHERE a.ts#=b.ts# AND
> TRUNC(a.creation_time) >= '01-Jan-05'
> GROUP BY b.name,TO_CHAR(a.creation_time,'Mon-yy') ORDER BY
> b.name,TO_DATE(TO_CHAR(a.creation_time,'Mon-yy'),'Mon-yy');
>
> DATABASE growth month wise -
> ----------------------------------------------------------------------------------------------------
>
> SELECT TO_CHAR(creation_time,'Month,YYYY') "Month",
> ROUND(SUM(bytes/1024/1024/1024),2) "Size in GB"
> FROM v$datafile
> WHERE TRUNC(creation_time) >= '01-jan-05'
> GROUP BY
> TO_CHAR(creation_time,'Month,YYYY'),TO_CHAR(creation_time,'YYYYMM')
> ORDER BY TO_CHAR(creation_time,'YYYYMM')
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> DATAFILE Addition Info. ex. you want to see the information of IEXD tablespace
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
SELECT FILE#, TO_CHAR(creation_time, 'DD/MON/YYYY HH24:MI'), ts#, status,bytes/(1024*1024) AS "Size MB", name FROM v$datafile WHERE TS# = (SELECT TS# FROM v$tablespace WHERE name ='IEXD') ORDER BY v$datafile.creation_time DESC ,FILE# DESC;
>
>

> /*****************************************************************/
>
>
> SELECT cr.REQUEST_ID,
> cr.PHASE_CODE,
> cr.STATUS_CODE,
> cr.NUMBER_OF_ARGUMENTS,
> cr.ARGUMENT_TEXT,
> cr.CONCURRENT_PROGRAM_ID,
> cp.CONCURRENT_PROGRAM_ID,
> cp.USER_CONCURRENT_PROGRAM_NAME,
> cr.REQUEST_DATE,
> cr.REQUESTED_START_DATE,
> cr.ACTUAL_START_DATE,
> cr.ACTUAL_COMPLETION_DATE
> FROM FND_CONCURRENT_PROGRAMS_VL cp,
> FND_CONCURRENT_REQUESTS cr
> WHERE cp.CONCURRENT_PROGRAM_ID = cr.CONCURRENT_PROGRAM_ID
> AND cp.USER_CONCURRENT_PROGRAM_NAME ='Purge Obsolete Workflow
> Runtime Data'
> ORDER BY requested_start_date DESC
>
> /******* Trace file name of concurrent running ********/
> SELECT 'Request id: '||request_id ,
> 'Trace id: '||oracle_Process_id,
> 'Trace Flag: '||req.enable_trace,
> 'Trace Name:
> '||dest.value||'/'||lower(dbnm.value)||'_ora_'||oracle_process_id||'.trc',
> 'Prog. Name: '||prog.user_concurrent_program_name,
> 'File Name: '||execname.execution_file_name|| execname.subroutine_name ,
> 'Status : '||decode(phase_code,'R','Running')
> ||'-'||decode(status_code,'R','Normal'),
> 'SID Serial: '||ses.sid||','|| ses.serial#,
> 'Module : '||ses.module
> from fnd_concurrent_requests req, v$session ses, v$process proc,
> v$parameter dest, v$parameter dbnm, fnd_concurrent_programs_vl prog,
> fnd_executables execname
> where req.request_id = :request_id
> and req.oracle_process_id=proc.spid(+)
> and proc.addr = ses.paddr(+)
> and dest.name='user_dump_dest'
> and dbnm.name='db_name'
> and req.concurrent_program_id = prog.concurrent_program_id
> and req.program_application_id = prog.application_id
> and prog.application_id = execname.application_id
> and prog.executable_id=execname.executable_id;
>
>
SELECT SUM(bytes/1024/1024) FROM dba_free_space WHERE tablespace_name='IEXD'
>
> SELECT cr.REQUEST_ID,
> cr.PHASE_CODE,
> cr.STATUS_CODE,
> cr.NUMBER_OF_ARGUMENTS,
> cr.ARGUMENT_TEXT,
> cr.CONCURRENT_PROGRAM_ID,
> cp.CONCURRENT_PROGRAM_ID,
> cp.USER_CONCURRENT_PROGRAM_NAME,
> cr.REQUEST_DATE,
> cr.REQUESTED_START_DATE,
> cr.ACTUAL_START_DATE,
> cr.ACTUAL_COMPLETION_DATE
> FROM FND_CONCURRENT_PROGRAMS_VL cp,
> FND_CONCURRENT_REQUESTS cr
> WHERE cp.CONCURRENT_PROGRAM_ID = cr.CONCURRENT_PROGRAM_ID
> AND cp.USER_CONCURRENT_PROGRAM_NAME ='HTPROMOUPLOADPRO'
> ORDER BY requested_start_date DESC
>
> select * from v$session where sid=190
>
> select * from v$sqltext where hash_value='1172720175' order by piece
>
>
>
> /------------------------------To check the tablespace free space---------/
>
> select fs.tablespace_name "Tablespace", fs.freespace "Free
> MB",df.totalspace "Total MB",
> round(100 * (fs.freespace / df.totalspace)) "Pct. Free"
> from (select tablespace_name,round(sum(bytes) / 1048576) TotalSpace
> from dba_data_files group by tablespace_name ) df,
> (select tablespace_name,round(sum(bytes) / 1048576) FreeSpace
> from dba_free_space group by tablespace_name) fs where df.tablespace_name =
> fs.tablespace_name order by 2 desc
>
> /----------------------------------------------------------------------------------------------------------------/
>
> /---------------------------------------Long running queries time left
> out----------------------/
>
> SELECT
> sid,serial#,USERNAME,opname,start_time,ROUND(((totalwork-sofar)/totalwork),4)*100
>
> "Pct Remaining", MESSAGE,time_remaining FROM v$session_longops WHERE
> time_remaining >0
>
> /----------------------------------------------------------------------------------------------------------------/
>
>
>
> /------------------------------------------To check the tablespace free
> space-------------------------------------/
>
>
> select tablespace_name,max(bytes/1024/1024) from dba_free_space group by
> tablespace_name order by 2 desc
>
>
> /----------------------------------------------------------------------------------------------------------------/
>
>
>
> /oracle/ncrmprddata/csx198.dbf
>
>
> alter tablespace IEXD add datafile '/eb_rdo0_p/oradata/pnoltpdata/iexd103.dbf' size 4g
> 2040m;

select * from v$fast_start_transactions;

SQL> alter tablespace IEXD add datafile '/eb_rdo0_p/oradata/pnoltpdata/iexd103.dbf' size 4082m;
Tablespace altered.
===================tablespace usage=======================
select * from (select s.sid,s.status, s.sql_hash_value sesshash,s.username, u.tablespace,
                              sum(u.blocks*p.value/1024/1024) mbused , sum(u.extents) noexts, nvl(s.module,s.program) proginfo,
                              floor(last_call_et/3600)||':'||floor(mod(last_call_et,3600)/60)||':'||mod(mod(last_call_et,3600),60) lastcallet
                       from   v$sort_usage u, v$session s, v$parameter p
                       where  u.session_addr = s.saddr
                       and    p.name = 'db_block_size'
                       group  by sid,status,sql_hash_value,sqlhash,s.username,tablespace,nvl(s.module,s.program),
                                 floor(last_call_et/3600)||':'||floor(mod(last_call_et,3600)/60)||':'||mod(mod(last_call_et,3600),60)
                       order  by 6 desc,3)
        where  rownum < 11;

============================
select to_char(actual_start_date,'DD-MM-YY HH24:MI'),request_id from fnd_concurrent_requests where oracle_process_id=10583 order by 1;
===========printer=========
SQL> update fnd_profile_option_values set profile_option_value='' where profile_option_id in (select profile_option_id from fnd_profile_options where profile_option_name like 'PRINTER') and profile_option_value like 'ACP_GKJ_ADMIN';
1 row updated.
SQL> select fo.profile_option_id,fv.profile_option_value from fnd_profile_option_values fv,fnd_profile_options fo where fo.profile_option_name like 'PRINTER' and fv.profile_option_id=fo.profile_option_id and fv.profile_option_value like 'ACP_GKJ_A%';
===========================

SQL> update fnd_concurrent_requests set PHASE_CODE='C', STATUS_CODE='T' where REQUEST_ID in (6297322,6297320);
 2 row updated

SQL> update fnd_concurrent_requests set PHASE_CODE='C', STATUS_CODE='T' where REQUEST_ID='6297143';
1 row updated.

SQL> select sysdate from dual@APS_DBLINK;
SYSDATE
---------------
18-NOV-09

SQL> select sysdate from dual@D_DNOLTP;
SYSDATE
---------------
18-NOV-09

$ strings -a WSHUTCOB.pls| grep Header | grep WSHUTCOB  --> to find the versions




Tuesday, 8 March 2011

ORA-28001: the password has expired (DBD ERROR: OCISessionBegin).



A. Verify if the password is expired.
 1.select username,ACCOUNT_STATUS,EXPIRY_DATE from dba_users where username='DBSNMP';

USERNAME                       ACCOUNT_STATUS                   EXPIRY_DA
------------------------------ -------------------------------- ---------
DBSNMP                         EXPIRED                                             19-DEC-10

B. If the password is expired and you don’t have the password then take the encrypted password using the below query.

 2.SQL> select PASSWORD from dba_users where username='DBSNMP';


 PASSWORD
 ------------------------------
 46169788712239BD

C. Check the profile value for that user .
3. SQL> select PROFILE from dba_users where username='DBSNMP';

PROFILE
------------------------------
APP_QUERY


D. Change the profile value to default temporarily.

4. SQL> alter user DBSNMP PROFILE default;
User altered.

E. Verify if the change is reflected.

5. SQL> select PROFILE from dba_users where username='DBSNMP';
PROFILE
------------------------------
DEFAULT

F. Reset the password using the below command to its old password as in step 2.
6. SQL> alter user DBSNMP identified by values '46169788712239BD';
User altered.

G. Now check if the account is open.
7. SQL> select username,ACCOUNT_STATUS,EXPIRY_DATE from dba_users where username='DBSNMP';
USERNAME                       ACCOUNT_STATUS                   EXPIRY_DA
------------------------------ -------------------------------- ---------
DBSNMP                         OPEN
H. Reset the profile value back to its original as in step 3.

8. SQL> alter user DBSNMP PROFILE APP_QUERY;
User altered.

I. Verify if the change has been reflected and it is the same as it was earlier.
9. SQL> select PROFILE from dba_users where username='DBSNMP';
PROFILE
------------------------------
APP_QUERY
**************   DONE   **************