Showing posts with label ER DIAGRAMS. Show all posts
Showing posts with label ER DIAGRAMS. Show all posts

Friday, April 17, 2020

Viewing the actual explain plan of Query

step1: add /*+ gather_plan_statistics */ hint in select statement as shown below.

select /*+ gather_plan_statistics */
e.first_name,d.department_name,j.job_title,j.job_id
from
hr.employees e,
hr.departments d,
hr.jobs j
where
e.job_id=j.job_id
and e.department_id=d.department_id
and j.job_title in ('Purchasing Clerk','Marketing Manager','Administration Assistant')
--and e.first_name in ('Sigal','Alexander','Jennifer','Susan')
;


step2: execute
 SELECT *  FROM  TABLE(DBMS_XPLAN.DISPLAY_CURSOR(null,null,'ALLSTATS LAST')) ;
A-rows shows actually resulted query where as E-rows shows estimated row count.

Thursday, February 26, 2015

EBS QUERY TO GET THE PARTY REALTIONS AND ER DIAGRAM RELATED TO IT

ER DIAGRAM:

QUERY FOR REFERENCE:
SELECT cacct.account_number cust_account,
      cust.party_name customer_name,
      crole.role_type contact_role_type,
      cont.person_last_name contact_last_name,
      cont.person_first_name contact_first_name,
      cont.person_name_suffix contact_suffix,
      cont.party_name contact_name,
      rparty.party_name relationship_party_name
    FROM ar.hz_relationships rel
    JOIN ar.hz_parties cust
    ON rel.subject_id = cust.party_id
    JOIN ar.hz_parties cont
    ON rel.object_id = cont.party_id
    JOIN ar.hz_parties rparty
    ON rel.party_id = rparty.party_id
    JOIN ar.hz_cust_accounts cacct
    ON rel.subject_id = cacct.party_id
    JOIN ar.hz_cust_account_roles crole
    ON cacct.cust_account_id    = crole.cust_account_id
    AND rel.party_id            = crole.party_id
    WHERE rel.relationship_code = 'CONTACT'
    AND rel.object_table_name   = 'HZ_PARTIES'
    AND rel.subject_table_name  = 'HZ_PARTIES'
    AND rel.subject_type        = 'ORGANIZATION'
    AND rel.object_type         = 'PERSON'
    AND rel.directional_flag    = 'B'
    AND rel.relationship_type   = 'CONTACT'
    AND crole.role_type         = 'CONTACT'
    AND rparty.party_type       = 'PARTY_RELATIONSHIP'
    ORDER BY 1,4,5;