I'm having problems when using the Prebuilt Table option in a MV in Oracle 12. This code works fine:
CREATE TABLE empt
( ename VARCHAR2(20),
empno INTEGER PRIMARY KEY);
CREATE MATERIALIZED VIEW LOG ON empt
WITH SEQUENCE , rowid (empno)
INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW empt_MV
REFRESH FAST ON COMMIT
WITH ROWID
AS
SELECT count(*) numberofemps
FROM empt ;
INSERT INTO empt VALUES ('A',1);
COMMIT;
SELECT * FROM empt_MV;
Previous Select return, as expected:
NUMBEROFEMPS
------------
1
But, if I use the ON PREBUILT TABLE option, nothing happens. I mean, the MV remains empty:
drop materialized view empt_mv;
drop materialized view log on empt;
drop table empt;
CREATE TABLE empt
( ename VARCHAR2(20),
empno INTEGER PRIMARY KEY);
CREATE MATERIALIZED VIEW LOG ON empt
WITH SEQUENCE , rowid (empno)
INCLUDING NEW VALUES;
CREATE TABLE empt_MV (
numberofemps NUMBER);
CREATE MATERIALIZED VIEW empt_MV
ON PREBUILT TABLE
REFRESH FAST ON COMMIT
WITH ROWID
AS
SELECT count(*) numberofemps
FROM empt ;
INSERT INTO empt VALUES ('A',1);
COMMIT;
SELECT * FROM empt_MV;
Previous Selects returns no rows.
Anyone knows what happens?
You can't use REFRESH FAST
if you are employing WITH ROWID
- on your prebuilt table. WITH ROWID Clause
This varies greatly by Oracle version.
Use the instructions provided in the relevant documentation, which will show you how to determine the fast refresh capabilities in your particular situation using DBMS_MView.Explain_MView.
12.1: https://docs.oracle.com/database/121/REPLN/repmview.htm#REPLN304
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.