Oracle物化视图

--远程建立物化视图: 
   --要求:DB1,DB2 要在DB2中建立物化视图,基表是DB1中的mytest表.
   --步骤:1.在DB2中建立dblink可以访问db1,
create database link DL_DB1 connect to db1username identified by db1password using 'db1servicename';
   --如果没有在tnsnames.ora中建立连接可以这样写
    create database link DL_DB1 connect to db1username identified by db1password using '(DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = db1)
    )
  )'
  --查看连接的sql
  select * from all_db_links;

  --2.在db1中建立物化视图日志
  create materialized view log on mytest2 with primary key;
  --3.在db2中建立视图
  create materialized view v_mytest
     refresh fast on demand 
     with primary key
     start with sysdate next sysdate+1/1440
     as select * from mytest;

其中 关于物化视图的参数信参考http://blog.sina.com.cn/s/blog_6ceed3280100xcdv.html      

你可能感兴趣的:(oracle,sql,刷新,物化视图刷新,跨库物化视图)