简体   繁体   中英

ORACLE - materialized view

I am trying to create materialazed view.

I have 2 databazses ORA1 and ORA2. I have table POKUS on ORA1 and I am trying to create view on ORA2 which change every time when I change and commint changes on ORA1 in table POKUS.

This is my query. but it is not working:

CREATE MATERIALIZED VIEW  
REPLIKOVANY_POKUS2 
REFRESH FAST START WITH 
    SYSDATE NEXT SYSDATE + 1/24/60 
ENABLE QUERY REWRITE AS 
    SELECT * 
    FROM dovondrda3.POKUS@ora1.uhk.cz;

Can you help me pleas

which change every time when I change and commint changes on ORA1

Well, you can't do that, not over database link as refreshing on commit won't work when remote database is involved. It is documented somewhere in Data Warehousing guide; search for it, if you want.

Remote database:

SQL> create table a1_brisime as
  2  select * from tom
  3  where sifra = '0387779';

Table created.

SQL> alter table a1_brisime add constraint pkab primary key (sifra);

Table altered.

SQL> create materialized view log on a1_brisime;

Materialized view log created.

SQL>

Local database:

SQL> create materialized view mv_test
  2  refresh fast on commit as
  3  select sifra, naziv
  4  from a1_brisime@dbl_test
create materialized view mv_test
*
ERROR at line 1:
ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view


SQL>

As I said - it won't work. Therefore, switch to another option, eg on demand :

SQL> create materialized view mv_test
  2  refresh on demand as
  3  select sifra, naziv
  4  from a1_brisime@dbl_test

Materialized view created.

SQL>

Or scheduled (as you tried):

SQL> create materialized view mv_test
  2  refresh complete
  3  start with sysdate
  4  next sysdate + 1/24/60
  5  as
  6  select sifra, naziv
  7  from a1_brisime@dbl_test

Materialized view created.

SQL>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM