Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Oracle uses materialized views to synchronize table data

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Create the original table and materialized view log

SQL > create table T1 (id int,name varchar2 (30)), Table created.SQL > alter table T1 add constraint pk_t1 primary key (id) using index;Table altered.SQL > create materialized view log on T1 with primary key;Materialized view log created.2. Create a target table and materialized view here I create a materialized view of refresh fast on commit type SQL > create table T2 as select * from T1 where 1 objective 2 position Table created.SQL > create materialized view T2 on prebuilt table refresh fast on commit as select * from T1 alternate material view created.3. A simple test inserts a piece of data into T1, and there exists data SQL > insert into T1 values (1 row created.SQL > commit;Commit complete.SQL > select * from T2) as soon as T2 is submitted. ID NAME- 1 A4.ddl test through the test, we found that the materialized view does not support ddl statements. We add a column and a rename column to T1 SQL > alter table T1 add ddl_test int;Table altered.SQL > alter table T1 rename column name to names;Table altered.SQL > select * from T2. ID NAME- 1 A 2 4SQL > insert into T1 values; 1 row created.SQL > commit;Commit complete.SQL > select * from T1 ID NAMES DDL_TEST- 1 A 2 4 3 x1234SQL > select * from T2 ID NAME- 1 A 2 4

When we find that the data has not come, let's take a look at the definition and state of the materialized view.

SQL > select dbms_metadata.get_ddl ('MATERIALIZED_VIEW','T2') from dual DBMS_METADATA.GET_DDL ('MATERIALIZED_VIEW','T2')-CREATE MATERIALIZED VIEW "SCOTT". "T2" ("ID", "NAME") ON PREBUILT TABLE WITHSQL > select staleness from user_mviews STALENESS-COMPILATION_ERROR

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report