Create Mview step by step

本文详细介绍如何在Oracle数据库中创建Mview(物化视图),包括连接实例、检查Mview是否存在及创建过程。此外还介绍了如何授予用户权限并创建同义词。

After completing this document, you should be able to create new mview.

1、  To facilitate the explanation , as a sample of creating mview at tetrix21_tkudpx05.

 

Operation Information:

Instance      Tetrix21_tkudpx05

Schema        PRDADMC

   Mview name    PARAM_FLUX_SENDER

First , running the PL/SQL software, connecting to tetrix21_tkudpx06 by dba account.

2When Connected the instance, we run the statement ‘select * from dba_db_links’ to get the current db_link name.

3We logon by PRDADMC.First, you need know, what’s schema and mview will be created. 

4Executing ‘select * from PARAM_FLUX_SENDER;’ , to check whether or not the Mview exist.

5Executing select * from PARAM_FLUX_SENDER@ TETRIX21_TKUDBX31.DKTETRIX.NET;’ , to check the master Mview availability.(Red font need be replaced to step 2 db_link name)

6If all above are OK, The following statement to create the mview.

.(Red font need be replaced to step 2 db_link name)

 
  
  1. CREATE MATERIALIZED VIEW PRDADMC.PARAM_FLUX_SENDER TABLESPACE PRDADMC_SNAP_DATA 
  2.  
  3. BUILD IMMEDIATE USING INDEX TABLESPACE PRDADMC_SNAP_INDEX  REFRESH FORCE ON DEMAND AS 
  4.  
  5. SELECT * FROM "PRDADMC"."PARAM_FLUX_SENDER"@TETRIX21_TKUDBX31.DKTETRIX.NET

 7Executing select * from user_refresh;

8We need replace the RNAME value of script (statement in red),using step 7 select result.

 
  
  1. begin 
  2.  
  3.   DBMS_REFRESH.ADD(name => 'PRDADMC. R_PRDADMC_TKUDBX31_1',list => 'PRDADMC.PARAM_FLUX_SENDER',lax => TRUE); 
  4.  
  5. end; 
  6.  

9Creating the materialized view log. Attention, all the red font, you need to change.

 
  
  1. CREATE MATERIALIZED VIEW LOG ON PRDADMC.PARAM_FLUX_SENDER TABLESPACE PRDADMC_SNAP_DATA


10Please use this SQL to know how many slaves in this instance.

 
  
  1. select mowner, r.snapsite, count(*) 
  2.  
  3. from   sys.slog$ s, sys.reg_snap$ r 
  4.  
  5. where  s.snapid=r.snapshot_id(+) 
  6.  
  7. group by mowner, r.snapsite 
  8.  
  9. order by 1 

 

11When we know the slaves, we need to operate all the step at every instance.

 

12We need grant right to VISU_xxxx account, and create synonym.

 

 
  
  1. grant select on PRDADMC.REF_SPECIFIC_CUSTOMER  to visu_prdadmc;  
  2.  
  3. create synonym visu_prdadmc.REF_SPECIFIC_CUSTOMER  for PRDADMC.REF_SPECIFIC_CUSTOMER; 
  4.  
  5. alter session set current_schemavisu_prdadmc
  6.  
  7. select * from dba_synonyms where table_name='REF_SPECIFIC_CUSTOMER' 









本文转自 hsbxxl 51CTO博客,原文链接:http://blog.51cto.com/hsbxxl/763140,如需转载请自行联系原作者

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值