1. 物化视图由于是物理真实存在的,故可以创建索引。
--为基表创建MLOG
--创建物化视图时应先创建存储的日志空间,否则建MV时报错
--ORA-23413: table "SCOTT"."EMP" does not have a materialized view log
create materialized view log on
scott.emptablespace test
/
--创建物化视图create materialized view test_mv
tablespace test
parallel (degree 4)
build immediate refresh fast
enable query rewrite
as
select * from
scott.emp/
--查看一下结果,果然很符合物化视图的定义,一个表+一个视图SQL> select object_name, object_type from user_objects where object_name = 'TEST_MV';
OBJECT_NAME OBJECT_TYPE
----------- --------
TEST_MV TABLE
TEST_MV MATERIALIZED VIEW
SQL> select mview_name, container_name from user_mviews;
MVIEW_NAME CONTAINER_NAME
---------------- ------------------------------
TEST_MV TEST_MV
(这就是那个存储表)--查看MLOG的情况--注意:MLOG的所属和MV的所属并不是同一个SQL> select log_owner, master, log_table from dba_mview_logs
LOG_OWNER MASTER LOG_TABLE
---------------------------------
SCOTT EMP MLOG$_EMP
(MLOG其实也就是一个表)SQL> desc scott.
mlog$_emp;
Name Type
-------------------------------
EMPNO NUMBER(4)
SNAPTIME$$ DATE
DMLTYPE$$ VARCHAR2(1)
OLD_NEW$$ VARCHAR2(1)
CHANGE_VECTOR$$ RAW(255)
--删除MLOGdrop materialized view log on 物化视图所依赖的表名;
--删除物化视图drop materialized view 物化视图名;
posted on 2010-01-13 00:04
Jcat 阅读(522)
评论(2) 编辑 收藏 所属分类:
Database