EXPLAIN PLAN FOR

10g以前的版本中,需要单独创建PLAN_TABLE并授予,10g中自动创建PLAN_TABLE$不再需要这一步骤
下面是10g之前初始化PLAN_TABLE需要创建的步骤:
SQL> @?/rdbms/admin/utlxplan.sql
SQL> create public synonym plan_table for plan_table;

SQL> grant all on plan_table to public;


EXPLAIN PLAN FOR 
with YJFX as (SELECT a.pi_code,a.month_id,a.pi_name,a.pi_sort_num,sum(pi_val) as pi_val 
FROM L2_Cw_Yjfx_Final a,
(SELECT ACCOUNT_NUMBER
  FROM DM_ZMMC_ACCOUNT
 WHERE (ACCOUNT_NUMBER = 'C01' OR ORG_ID_P = 'C01' OR ORG_ID_PP = 'C01' OR
       ORG_ID_PPP = 'C01')
   AND THE_YEAR = SUBSTR('20130808', 1, 4)
   AND THE_MONTH = SUBSTR('20130808', 5, 2)
   AND (ACCOUNT_NUMBER IN
       (SELECT DISTINCT RES.RES_VALUE
           FROM PORTAL.BI_SYS_RESOURCE   RES,
                PORTAL.BI_SYS_USER_RES   UR,
                PORTAL.BI_SYS_USERINFO   U,
                PORTAL.BI_SYS_RES_PERMIS RP
          WHERE RES.RES_SHOWTYPE = 'ORG'
            AND RES.RES_VALUE IS NOT NULL
            AND RES.RES_ROOTID = '34140001033'
            AND RES.RES_ID = UR.RES_ID
            AND UR.USER_PKID = U.USER_PKID
            AND RES.RES_ID = RP.RES_PERMID
            AND RP.RES_MENUID = 4140002521
            AND U.LOGIN_NAME = '10000000'
            UNION ALL 
            SELECT 'D406' FROM dual
            UNION ALL 
            SELECT 'B205' FROM dual
            UNION ALL 
            SELECT 'D412' FROM dual
            UNION ALL 
            SELECT 'C1008' FROM dual
            UNION ALL 
            SELECT 'C100801' FROM dual
            UNION ALL 
            SELECT 'B206' FROM dual
            UNION ALL 
            SELECT 'D404' FROM dual
            UNION ALL 
            SELECT 'D403' FROM dual
            UNION ALL 
            SELECT 'D410' FROM dual
            UNION ALL 
            SELECT 'B2011' FROM dual
            ))) b 
where a.account_no=b.account_number
group by a.pi_code,a.month_id,a.pi_name,a.pi_sort_num
order by a.pi_sort_num)

SELECT * from yjfx;

select * from table(DBMS_XPLAN.display);

你可能感兴趣的:(for,EXPLAIN,plan)