oracle创建物化视图
----- 需要 创建 权限视图
CREATE MATERIALIZED VIEW V_INTER_ORG_CSA_GRANT
TABLESPACE TBS_LDC --保存表空间
BUILD DEFERRED --延迟刷新不立即刷新
REFRESH FORCE --如果可以快速刷新则进行快速刷新,否则完全刷新
WITH ROWID --根据rowid刷新(默认是主键)
ON DEMAND --按照指定方式刷新
START WITH SYSDATE NEXT SYSDATE + 6 / 24 AS --- 每6小时刷新一次
SELECT DISTINCT REL.INTER_ORG_ID
FROM TB_PTY_INTER_ORG_REL REL ----WHERE rel.inter_org_id=438051
CONNECT BY PRIOR REL.UP_INTER_ORG_ID = REL.INTER_ORG_ID
START WITH REL.INTER_ORG_ID IN
(SELECT DISTINCT EMORG.IN_ORG_ID
FROM TB_SYS_PRIVILEGE A,
TB_SYS_ROLE_PRIVILEGE B,
TB_SYS_EMPEE_ROLE C,
TB_SYS_EMPEE_ORG EMORG
WHERE A.PRIVILEGE_ID = B.PRIVILEGE_ID
AND B.ROLE_ID = C.ROLE_ID
AND C.EMPEE_ID = EMORG.EMPEE_ID
AND A.APP_ID IN (151))