我在甲骨文12.這段代碼使用預先建立的表選項的MV時遇到了問題工作正常查看不刷新:如預期甲骨文:物化使用預建表時
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;
上選擇回報, :
NUMBEROFEMPS
------------
1
但是,如果我使用ON PREBUILT TABLE選項,則什麼都不會發生。我的意思是,MV仍然是空的:
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返回沒有行。
任何人都知道會發生什麼?