日期:2014-05-16  浏览次数:20480 次

[每日一题] 11gOCP 1z0-053 :2013-10-10 materialized view---- online redefinition ...................35

转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/12656175


正确答案:A

 

     对于这道题物化视图,我直接用实验来证明答案,实际把OCP的题目转化为实验就是OCM的题目了,记得在OCM考试中就有好几道物化视图的题目,如下就是OCM的原题:

  

section 4 :    
1. Fast Refreshable Materialized View
 1.1 Using the query found in the mviewl.txt text file, create a fast refreshable materialized view named PROD_MV in the SH schema.

2. Creating an Updatable Materialized View
 2.1 Using the HR.EMPLOYEES table in the PROD database, create an updatable materialized view in the EMREP database named EMP_UPD_MV consisting of the following columns: EMPLOYEE_ID , FIRST_NAME , LAST_NAME , PHONE_NUMBER , SALARY.

    实际上OCM考试并不难,我个人感觉OCP的考试比OCM的难,特别是11的OCP,就拿1z0-053这门课来说通过率只有66%,甚至50%,之所以通过率这么低,题库一直在变,现在这门课有1000多道题库了,而且考试随机抽取,答案顺序全部打乱了,而且有50%不定项选择,运气不好还可以抽到题库中没的题目,很多学生背题库,由于OCP的题太理论了面又广,背了就忘记,容易混晓,哪怕我是去背那1000道也感觉力不重心,考的真有点变态了,题库要看到恶吐了,哈哈希望大家要做好准备,有啥问题可以跟我一起讨论。

       对于OCM的题目量少,题目也是固定的,把这些题目在平日里多强练习,熟能生巧。好闲话少叙,我来用实验证明上面答案A。(记住要想成为真正的OCP,每道题像我这样去练习,你就成功了。)

  

1、  先建一个表ADMIN_EMP

gyj@OCM> create table ADMIN_EMP as select EMPLOYEE_ID EMPNO, FIRST_NAME ENAME, DEPARTMENT_ID DEPTNO, SALARY  SAL from hr.EMPLOYEES;

Table created.

2、  对表ADMIN_EMP的列ENAME建索引

gyj@OCM> create index ENAME_IDX on ADMIN_EMP(ENAME);

Index created.

3、  对表ADMI_EMP创建视化视图日志

gyj@OCM> CREATE MATERIALIZED VIEW LOG ON gyj. ADMIN_EMP
  2  WITH  ROWID, SEQUENCE  (EMPNO, ENAME, DEPTNO, SAL) 
  3  INCLUDING NEW VALUES;

Materialized view log created.

(INCLUDING NEW VALUES这个就相当于插入触发器,有行插入了,将新值记录到物化视图日志中

如果没有including new vlaueInsert后不能快速刷新。只能全量)

 

4、对表ADMI_EMP创建视化视图

gyj@OCM> CREATE MATERIALIZED VIEW EMP_MV  USING NO INDEX 
  2  REFRESH FAST WITH ROWID 
  3  ON DEMAND ENABLE 
  4  QUERY REWRITE 
  5  AS SELECT EMPNO, ENAME, DEPTNO, SAL from ADMIN_EMP;

Materialized view created.

5、  查表和物化视图的数据,数据一样。

gyj@OCM>select count(*) from admin_emp;

 

  COUNT(*)

----------

       107

 

gyj@OCM>select count(*) from emp_mv;

 

  COUNT(*)

----------

       107

 

6、  把ADMIN_EMP的表迁到另一表空间

gyj@OCM> select tablespace_name from user_tables where table_name='ADMIN_EMP';

TABLESPACE_NAME
------------------------------
GYJ
gyj@OCM> select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS
EXAMPLE
GYJ
TP1
gyj@OCM> alter table admin_emp move tablespace tp1;

Table altered.

 

7、  再次查表和物化视图的数据,数据一样没变

gyj@OCM> select count(*) from admin_emp;

  COUNT(*)
----------
       107

gyj@OCM> select count(*) from emp_mv;

  COUNT(*)
----------