Materialized view log creation - oracle

I have a materialized view on a table on remote DB using DB link.
The below query works and able to view the result.
select * from dept_owner.department#dept_link;
But getting error while trying to create a materialized view.
CREATE MATERIALIZED VIEW "ORADBA"."department" ("DEPT_NUM", "DEPT_NAME")
REFRESH FAST ON DEMAND START WITH sysdate+0 NEXT (trunc(sysdate + 1) + 5/24)
AS select DEPT_NUM,DEPT_NAME from dept_owner.department#dept_link;
Error,
ORA-23413: table "dept_owner"."department" does not have a
materialized view log
23413. 00000 - "table "%s"."%s" does not have a materialized view log"
*Cause: The fast refresh can not be performed because the master table
does not contain a materialized view log.
*Action: Use the CREATE MATERIALIZED VIEW LOG command to create a
materialized view log on the master table.
I created VIEW LOG in my DB for this view, but still getting the above error.
CREATE MATERIALIZED VIEW LOG ON "ORADBA"."DEPARTMENT" WITH ROWID EXCLUDING NEW VALUES;
I have the same materialized view on another environment with the same DB link and it works. Not sure what is missing here.
Questions:-
I have this materialized view on both the Dev DB and IT DB. IT DB materialized view is working for long time. Running into issue when creating the materialized view in Dev DB.
Do we need to create a VIEW LOG on the remote DB link DB and give grants for users from both Dev and IT DB?
Do we need to create VIEW LOG in Dev and IT DB?

Related

Permissions error encountered during Oracle materialized view creation

I am trying to create a materialized view in Oracle 19C.
The schema I'm creating it in (schema B) has CREATE TABLE and CREATE MATERIALIZED VIEW permissions and when I run the following code
create materialized view matview_info build immediate refresh on demand as select * from a.info;
it generates the view perfectly well.
However, when I drop the materialized view and then try and set it up again, but with automatic refresh through refresh fast start as follows:
CREATE MATERIALIZED VIEW matview_info BUILD IMMEDIATE REFRESH FAST START WITH (SYSDATE) NEXT ((SYSDATE) + 3/ 24) WITH ROWID ON DEMAND DISABLE QUERY REWRITE AS SELECT * FROM a.info;
I receive the following error message:
[Error] Execution (16: 25): ORA-12018: following error encountered during code generation for "B"."MATVIEW_INFO"
ORA-00942: table or view does not exist
My TOAD client indicates the error is referencing the 'a.info' table - but this is working fine when I don't include the 'fast start' part of the code. I also have set up a materialized view log on the base table.
Execution of a simple select on a.info from schema B returns data from the table. When logged in as schema A, I have given schema B select and references on a.info.
Can anyone advise please as to the cause of this ORA-00942 error and how I can potentially solve it?
Thanks

SQL Error: ORA-32361

When I create real-Time Materialized Views in Oracle Database 12c Release 2 I get SQL Error: ORA-32361. What does it mean?
My view is simple, without any aggregation.
CREATE MATERIALIZED VIEW example_t_mv
REFRESH FAST ON DEMAND
ENABLE QUERY REWRITE
ENABLE ON QUERY COMPUTATION
AS
SELECT et.some_value_1, et.some_value_2
FROM example_t et WHERE et.some_value_2 < 10;
SQL Error: ORA-32361: cannot ENABLE ON QUERY COMPUTATION for the
materialized view
Create MVLog and try to create the MV
CREATE MATERIALIZED VIEW LOG ON example_t
WITH ROWID, SEQUENCE(some_value_1, some_value_2)
INCLUDING NEW VALUES;

oracle 11g Thamaterialized views against another view

Good day,
Is it technically possible to create a materialized view against a another view in the master database (as opposed to a solid table)?
My DBA advises that oracle does not allow creation of materialized view logs against a view. IMO a view is pretty much the same as a table, so it ought to be possible.
Has anyone ever done this successfully (Oracle 11g).
The documentation is pretty clear about this:
Restrictions on Master Tables of Materialized View Logs
The following restrictions apply to master tables of materialized view logs:
You cannot create a materialized view log for a temporary table or for a view.
You cannot create a materialized view log for a master table with a virtual column.
A view is not pretty much the same as a table. It's a stored query, so it has no storage and DML is only possible through instead-of triggers. It doesn't have the basis for noticing an underlying data change.
Just thinking about it, in order to support a view log - even for a simple single-table view - an update to the view's base table would have to check if there were any views; check if any of those had materialized view logs; and then work out if the change needed to be logged - which would mean executing each view's query and looking at the entire result set. Imagine doing that for every change to the underlying table. And then imagine a more complicated view query, with aggregates or multiple tables, etc.
You'd effectively be materialising the view query to decide whether was a change that needed to be logged, to update an actual materialized view. This is partly what actual materialized views do - stop you having to repeatedly re-execute an expensive view query by tracking changes on the master table(s).
You have to create the materialized view logs on the (normal) view's base tables.

Failed to create a materialized view log on master table

CREATE MATERIALIZED VIEW LOG ON acquisitions
TABLESPACE users
WITH PRIMARY KEY
INCLUDING NEW VALUES;
I am trying to create a materialized view log on my master table acquisition. The master table is in the same database as materialized view. I am trying to satisfy all the criteria
to reproduce commit on refresh .Creating a mv log is one of those. But I got this error:
SQL Error: ORA-00439: feature not enabled: Advanced replication
00439. 00000 - "feature not enabled: %s"
*Cause: The specified feature is not enabled.
*Action: Do not attempt to use this feature.
I am using ORACLE 11g. Is this is bug in ORACLE 11g ?
CREATE MATERIALIZED VIEW LOG ON sales
WITH ROWID, SEQUENCE(amount_sold, time_id, prod_id)
INCLUDNG NEW VALUES; strong text
try this example ,may be it helps

changes in Materialized

I have one Materialized view on one server which is created by DB link.
There is one job running on that Mview. (created with dbms_refresh.make earlier).
Now I have created 3 new fields in original table.
My queries are.
1) Do I need to drop and create Mview again, if yes, do i need to create Mview log on main server again
2) What happens to job running on Mview , do i need to create it agin?
Also there are views created on Mview ,so
--If i run create or replace view query , will it create any problem?
Please guide.
Thanks!
If you need to include the new columns in your materialized view then yes you need to re-create the materialized view. You must explicitly drop the view as there is no "create or replace materialized view" statement.
DROP MATERIALIZED VIEW blah;
CREATE MATERIALIZED VIEW blah...
Dropping/recreating the materialized view should re-create the refresh job. Not 100% certain, but you should probably recreate the log as well.
And, if you don't need to include the new columns in your view, you really don't need to do anything...
After dropping/creating the materialized view, you should recompile the other views afterwards, because they may have become invalid.
You can check if that happened with
select *
from user_objects
where status = 'INVALID';
Recompile a view can be done with
alter view the_view compile;
or
exec dbms_utility.compile_schema(user);
This simply recompiles everything in your schema. Be sure to have no running jobs while doing this!

Resources