행위

오라클 mv

DB CAFE

Dbcafe (토론 | 기여)님의 2019년 7월 19일 (금) 09:13 판 (새 문서: = 오라클 M/V 생성 == <source lang=sql> -- 테이블 생성 create table t (x not null primary key, y not null) as select rownum x, mod(rownum, 10) y from dual connect by leve...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)
thumb_up 추천메뉴 바로가기


오라클 M/V 생성 =[편집]

-- 테이블 생성 
create table t (x not null primary key, y not null) as
  select rownum x, mod(rownum, 10) y from dual connect by level <= 1000;

-- M/V 생성 
create materialized view log on t with rowid (x, y) including new values;

create materialized view mv
refresh fast on demand
enable on query computation
enable query rewrite
as
  select y , count(*) c1
  from t
  group by y;

-- 테이블 입력 
insert into t
  select 1000+rownum, 1 from dual connect by level <= 100;

commit;

-- M/V rewrite 
select /*+ rewrite */y , count(*) from t
group by y;

-- M/V reflash 수동
select /*+ fresh_mv */* from mv;