SQL Error: ORA-32361 - oracle

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;

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

Hive - Incremental update materialized view

Suppose I have a transactional table t1 as
1,abc,4.5
2,xyz,3.7
And I create a materialized view on it :
> create materialized view t1_mv as select * from t1;
Then I update the table :
> insert into t1 values (3,"lmn",4.7)
Now when I want to update the view I have to execute following query :
> ALTER MATERIALIZED VIEW t1_mv REBUILD;
In above query rebuild operation triggers full scan on t1 table and rewrites materialized view.
As per Hive documentation : "Hive supports incremental view maintenance, i.e., only refresh data that was affected by the changes in the original source tables. Incremental view maintenance will decrease the rebuild step execution time. In addition, it will preserve LLAP cache for existing data in the materialized view." link to documentation
However the exact process is not mentioned about incremental update on materialized views,
My Questions are :
How to incrementally update materialized view ?
What is the role of LLAP cache in the process of incremental update ?

Materialized view log creation

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?

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

Redefine materialized view with no downtime

I have a materialized view that I need to redefine the SQL for. We have an external system that hits the view over a db link, and the monster view takes 5 minutes to refresh the data in the view. The only way I know how to redefine the SQL for a view is to drop it and recreate it, but it would be very bad if the external system couldn't find the table, or it didn't have a complete data set. I need to have as little downtime as possible.
Is there any way to do this natively or more elegantly than:
Create public synonym for materialized view and make everything that uses the view use the synonym instead.
Create new materialized view with new SQL
Change the synonym to point to the new view
Drop the old view.
I've got code to do this dynamically but it is getting really ugly. It seems like there should be a better way to handle this.
Oracle has a build in solution for that. Keep in mind that the mview declaration is separate from that of the table.
The original mview
create materialized view mv1 as select dept , count(*) as cnt from scott.emp;
we want to change the declaration so that only dept over 5 will be calculated
drop materialized view mv1 preserve table;
notice the PRESERVE TABLE clause - the table mv1 is not droped - only the mview layer.
desc mv1
now we create the mview with a different query on top of the existing table
create materialized view mv1 on prebuilt table as
select dept , count(*) as cnt from scott.emp where dept > 5;
notice the on prebuilt table clause. the mview is using the existing object.
exec dbms_mview.refresh_mview('mv1');

Resources