Permissions error encountered during Oracle materialized view creation - oracle

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

Related

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?

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;

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

Why does SQL Developer think there's an error in my materialized views?

I created some materialized views and Oracle SQL Developer puts a little red 'x' next to each of them. At the moment they are returning the correct information when I query them and running the following query in SQL Plus suggests that there are no errors:
SELECT * FROM USER_SNAPSHOTS
The ERROR column in this returns 0 for the materialized views in question.
Does anyone know why SQL Developer thinks there is an error? Is there anywhere else I can check?
UPDATE
Taking Patrick's advice I ran the following query:
SELECT * FROM ALL_MVIEWS
The COMPILE_STATE is 'NEEDS_COMPILE' for each view in question. What does this mean? Why would it need to be recompiled? None of the underlying tables have been changed.
To fix 'red' cross icon on views (actually it is a white cross over red background) due to NEEDS_COMPILE run the ALTER VIEW COMMAND.
ALTER VIEW MY_VIEW COMPILE;
Check ORACLE SQL Reference about ALTER VIEW.
http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_4004.htm
For some reason, simply refreshing the materialized views made the 'error' go away. So not a true error, more of a reminder that the data isn't up to date. I guess you can ignore it if the table structure hasn't actually changed then...
This can be caused by modifications to an underlying table that the materialized view is based on. For example: increasing the max size of a column in the table which is included in the materialized view.
To refresh the materialized view you can do the following:
BEGIN
DBMS_SNAPSHOT.REFRESH('Name of materialized view');
END;

Oracle - Unable to drop tables

This question is related to the one I posted yesterday but with further implications.
The situation is: I'm unable to drop ANY table. Here's an example:
SQL> CREATE TABLE FOO (BAR NUMBER) TABLESPACE SYSTEM
/
Table created.
SQL> SELECT COUNT(1) FROM FOO;
COUNT(1)
----------
0
SQL> DROP TABLE FOO;
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-00942: table or view does not exist
ORA-06512: at line 19
So, the table seems to exist but I'm not capable of dropping it.
Notice the error ORA-00604: error occurred at recursive SQL level 1. If I try to drop a non existing table, this error does not appear:
SQL> DROP TABLE NON_EXISTING_TABLE
ERROR at line 1:
ORA-00942: table or view does not exist
Somehow, the system is unable to find the table at dropping time.
The oracle installation and the DB itself is new (one day old).
EDIT - I retried this test using another tablespace and user (I just created ones) and I got a slightly different behaviour: using SYS, after I got the DROP error I can still SELECT from the table. However, using this new user, after I got the DROP error, I no longer can SELECT from the table.
Solution
We found the problem: the MDSYS.SDO_GEOR_SYSDATA_TABLE was missing, preventing the drop operation.The solution is to restore that table. Here is the complete solution, by Gaurav Soni (by the way, many thanks).
Run the script catmd.sql (located in $ORACLE_HOME/md/admin dir).
The catmd.sql script is the script that loads all objects needed by Oracle spatial in the database. Then drop the user.
you can also refer to oracle metalinks
Steps for Manual Installation of Oracle Spatial Data Option
Dropping user results in ORA-942 against SDO_GEOM_METADATA_TABLE
I'd suggest that you activate SQL tracing (ALTER SESSION SET SQL_TRACE=TRUE;) and try the drop again. This will generate a trace file on the server (in the udump directory) that will show all the SQL the session executed, including recursive statements. This should show you the recursive SQL statement that is failing.
I think the problem is that you created the table on system tablespace. You should create it on the user tablespace or create one to store your data.

Resources