Tuesday 29 November 2016

Important DBA Scripts



Hi Friends,

Many people as requested for some sql query which helpful in oracle. Please find the below SQL Query which are very important for any DBA. Hope these may useful and helpful. If need any more sql scripts, please let us know.

Script to get the session details of the sessions holding/waiting on a Library Cache Lock: -- very very important

select /*+ ordered */
           w.kgllktype "LockType",
           w.kgllkhdl  "ObjectHandle",
           q.sql_text  "ObjectName",
           h1.sid      "HoldingSID",
 decode(h.kgllkmod,0,'None',1,'Null',2,'Share',3,'Exclusive','Unknown') "Held",
 w1.sid       "WaitingSID",
 decode(w.kgllkreq,0,'None',1,'Null',2,'Share',3,'Exclusive','Unknown') "Request"
 from dba_kgllock w, dba_kgllock h, v$session w1, v$session h1, v$sql q
 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.kgllkhdl  = q.address(+)
      and w.kgllktype = h.kgllktype
      and w.kgllkhdl  = h.kgllkhdl
      and w.kgllkuse  = w1.saddr
      and h.kgllkuse  = h1.saddr
/


How to check Request ID status scripts:

select A.REQUEST_ID,TO_CHAR(A.ACTUAL_START_DATE,'DD-MON-YY HH24:MI:SS'),TO_CHAR(A.ACTUAL_COMPLETION_DATE,'DD-MON-YY HH24:MI:SS'),A.STATUS_CODE,A.PHASE_CODE,
B.CONCURRENT_PROGRAM_ID , B.CONCURRENT_PROGRAM_NAME 
from fnd_concurrent_requests A, fnd_concurrent_programs B
where request_id=&reqid AND
A.CONCURRENT_PROGRAM_ID = B.CONCURRENT_PROGRAM_ID ;

Scripts for Running Request ID details:
# This query returns all running concurrent manager requests
# there are no parameters required for running this query.

select oracle_process_id,request_id 
from applsys.fnd_concurrent_requests
where PHASE_CODE='R';

Find the details of the Request ID:

SELECT v.sid,v.serial#,s.sql_text,f.request_id
FROM v$session v,v$sqlarea s,v$process p,fnd_concurrent_requests f
WHERE f.request_id='&Request_ID'
AND ((v.process=f.os_process_id) OR (p.spid=f.os_process_id))
AND v.paddr=p.addr
AND v.sql_hash_value=s.hash_value;

OR

How to find Request ID to SID or request id details:

SELECT fr.request_id "REQ_ID", s.sid, s.serial#, s.lockwait, s.module, s.status, p.spid "S_PID", s.process "C_PID"
FROM
v$session s, v$process p, applsys.fnd_concurrent_requests fr, applsys.fnd_concurrent_processes fp
WHERE
s.paddr = p.addr
AND s.process = fp.os_process_id
AND fr.controlling_manager = fp.concurrent_process_id
AND fr.request_id = '&reqid';

How to find out SID from Request ID:

SELECT 'Request id: '||request_id ,
'SID Serial: '||ses.sid||','|| ses.serial#,
'Module : '||ses.module
FROM apps.fnd_concurrent_requests req, v$session ses, v$process proc,
v$parameter dest, v$parameter dbnm, apps.fnd_concurrent_programs_vl prog,
apps.fnd_executables execname 
WHERE
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
and request_id=’1343130’;

Script for Forms query:

# This query requires no parameters and will show you
# all forms that people in applications are using.
# It is similar to the user monitor screen in applications
#
#
#
set pause on
set pause '--more--'
column user_name format a20
column user_form_name format a25
column time format a8
column pid format 99999
column spid format 99999
column process format 99999
SELECT v$process.pid,spid,user_name,time,user_form_name
FROM fnd_signon_audit_view, v$process
WHERE fnd_signon_audit_view.pid = v$process.pid
/


Some more useful links:








For any query or suggestions, please write either in comment box or contact us @https://ora-data.blogspot.in/

Thanks,

23 comments:

  1. After checking out a few of the articles on your site, I treuly apppreciate
    your technique of blogging. I book-marked it to my
    bookmark website list and will be checking
    back in the near future. Take a look at my website too aand tell me what you think.

    ReplyDelete
    Replies

    1. Dear User,

      Thank you for your feedback.
      Sure, please let me know your web.

      Regards,
      ora-data Team

      Delete
  2. Howdy very nice site!! Guy .. Excellent .. Wonderful ..
    I will bookmark your site and take the feeds additionally?
    I'm glad to seek out a lot of helpful information here in the post, we'd like work out more strategies on this regard, thanks for sharing.
    . . . . .

    ReplyDelete

  3. Dear User,

    Thank you for your feedback.

    Regards,
    ora-data Team

    ReplyDelete
  4. When I originally commented I clicked the "Notify me when new comments are added" checkbox and
    now each time a comment is added I get three e-mails with the
    same comment. Is there any way you can remove people from that service?
    Bless you!

    ReplyDelete
  5. Thanks for one's marvelous posting! I genuinely enjoyed reading it, you may be a great author.
    I will make certain to bookmark your blog and will eventually come back someday.

    I want to encourage you continue your great job, have a nice morning!

    ReplyDelete
    Replies

    1. Dear User,

      Thank you very much for your valuable words and feedback.

      Regards,
      ora-data Team

      Delete
  6. I do not even know how I ended up here, but I thought this post was great.
    I don't know who you are but definitely you're going to a famous blogger
    if you aren't already ;) Cheers!

    ReplyDelete
    Replies
    1. Dear User,
      Thank you for your wishes and feedback.

      Regards,
      ora-data Team

      Delete
  7. Attractive section of content. I just stumbled upon your blog and in accession capital to assert
    that I get in fact enjoyed account your blog posts.
    Anyway I will be subscribing in your feeds and even I fulfillment you
    access consistently rapidly.

    ReplyDelete
    Replies

    1. Dear User,

      Thank you for your valuable feedback.

      Regards,
      ora-data Team

      Delete
  8. Aw, this was an extremely nice post. Taking a few minutes and actual
    effort to produce a great article… but what can I say… I put things off a whole lot and don't manage to
    get anything done.

    ReplyDelete
  9. hello!,I like your writing so a lot! percentage we be
    in contact exfra approximately your post on AOL? I need an expert on this house
    to solve mmy problem. Maay be that's you! Taking a look forward to peer you.

    ReplyDelete
    Replies
    1. Dear User,
      Thank you for your great feedback.
      Sorry, I have not much worked on AOL... but let me know the issue which I can help you as much as possible. :)

      Regards,
      ora-data Team

      Delete
  10. Really nice post . Keet it up please , it will help all the DBA's who ever needed

    ReplyDelete
  11. Greetings! Very helpful advice ѡithin this article!
    It is thhe ⅼittle cһanges tһat maқe tһe mօѕt importɑnt changes.
    Many thanks fоr sharing!

    ReplyDelete
  12. Wow, marvelous weblog layout! How long have you
    been blogging for? you make blogging look easy.
    The full look of your site is fantastic, let alone the content material!

    ReplyDelete
  13. That is really attention-grabbing, You are an excessively professional blogger.
    I've joined your feed and look ahead to in quest of extra of your excellent post.
    Also, I've shared your web site in my social
    networks

    ReplyDelete
  14. Your means of describing everything in this piece of writing is in fact pleasant, all be
    able to easily understand it, Thanks a lot.

    ReplyDelete
  15. Pretty! This has been an extremely wonderful post.

    Thank you for supplying this info.

    ReplyDelete
  16. It is appropriate time to make a few plans for the longer term and it is
    time to be happy. I've learn this post and if I may I wish to counsel you some interesting
    things or suggestions. Maybe you can write subsequent articles referring to this article.
    I want to learn even more issues approximately it!

    ReplyDelete
  17. What i don't understood is actually how you're not actually
    much more well-favored than you might be right
    now. You are very intelligent. You know thus considerably in terms of this topic, produced
    me individually imagine it from numerous varied angles.

    Its like men and women don't seem to be involved unless it is something to do with Girl gaga!
    Your individual stuffs nice. At all times care for it up!

    ReplyDelete

Thank you for your comments and suggestions. It's good to talk you.