SQL & PL/SQL :: Creating And Refreshing Materialized View Group From Another Schema?
Nov 27, 2012
I have a list of materialized views in schema A. I want to create a refresh group and then refresh it from Schema B (Dynamically-run time based on some criteria). What Grants are necessary on schema B in order for it to be able to create and refresh the groups on Materialized views in Schema A.
I know that one of the Options is to, GRANT ALTER ANY MATERIALIZED VIEW as a SYS user. But I do not have any SYS privileges.
Error:- ORA-02448: constraint does not exist ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2254 ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2460 ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2429 ORA-06512: at line 1
The Primary Key Constraint on the base table/MV is deferrable, the base table and the MV are in different schemas and the user trying to refresh the MV has an explicit grant on "ALTER ANY MATERILIZED VIEW" and "SELECT ANY TABLE" through a role.
Its refreshing successfully when I make the PK constraint (Base Table, MV) NOT DEFERRABLE (or) when I explicitly grant "SELECT ANY TABLE" to the user trying to refresh the MV.
I have a database schema with a Materialized View (MV) that updates a products table shown on a website. This schema was recently imported to an 11g database from 8i, but since this import I have been unable to refresh my schema's Materialized View.
The MV_PRODUCT_MASTER Materialized View attaches price data to product data that is stored in a normal WEB_PRODUCT table, and create an MV table as a result. The output MV table is what the website pulls data from to display to the site users. Since it is an MV table, this table cannot be edited directly. In order to change, say, a product description, I need to alter the description field in WEB_PRODUCT and manually refresh the MV_PRODUCT_MASTER table. Only through the refresh will the upstream edits appear in the MV_PRODUCT_MASTER table and be visible on the website.
In my old 7.6.0.11 copy of TOAD, I could manually refresh these MVs easily, by opening the "Snapshots" tab, right clicking on the MV I wanted to refresh and selecting the "Refresh" option. Since the schema was imported to 11g, I have been using the Oracle SQLDeveloper tool to manage the schema. SQLDeveloper doesn't have a clear method for manually refreshing an MV, or else the method I am using isn't working.
If I right click on the MV_PRODUCT_MASTER Materialized View object, and choose "Other Actions", I see the following choices:
I assumed that -Force Materialized View Refresh- was the right choice, and chose that. This option displays the SQL:
alter materialized view "WEBADMIN"."MV_PRODUCT_MASTER" consider fresh
When I apply this, I get the message: Materialized view - MV_PRODUCT_MASTER - has been set torefreshed. However, no changes appear in the MV output table. i.e. if I make a specific change to a row in the WEB_PRODUCT table, the change is not being carried into the MV_PRODUCT_MASTER table, so that indicated that the refresh is not actually happening. The MV table appears to believe it is being refreshed:
REWRITE_CAPABILITY GENERAL REFRESH_MODE DEMAND REFRESH_METHOD COMPLETE BUILD_MODE IMMEDIATE FAST_REFRESHABLE NO LAST_REFRESH_TYPE COMPLETE LAST_REFRESH_DATE 06-APR-10 STALENESS UNKNOWN
But it isn't showing any changes.What am I doing wrong? Is there a plain SQL statement I can run in order to run these refreshes, instead of using the SQLDeveloper GUI?
I'm trying to create a Materialized View on a remote database from a simple view. The reason is, the data owners don't want to grant explicit tables privileges to external subscribers.
A new schema is created to publish data in the form of a view. I've created mlogs on the master tables, and granted them to the subscriber, but it's still complaining about a missing primary key on the view. A primary key does exist in the master table.
Is there another work around for this situation without having to work inside the data sources' environment?
There are 2 databases, database A and database B. Database A is Oracle 11.2.0.2 which runs on linux and Database B is Oracle 11.2.0.2 which runs on windows xp machine. In database A, there are 100's of tables which are being updated every 10 minutes or 15 minutes. For reporting purpose, the developer wants to run report for the tables. But since database A is being updated every now and then, generating reports takes almost 15 to 20 minutes. So the reports can be generated in Database B. Once in a day the database B should have the updated data from database A so that the reports can be generated in database B with less time. What could be the best solution for the database B to have the updated data on daily basis from database A in oracle?
I am working on materialized view replication but i have an crucial issue. I have a refresh group which contain many MVs some are Read only and some are update but all are in Fast refresh mode (logs are created on both replication and MV sites on these objects) and are referentially integrated to each other i.e they have parent child relationship with each other as at replication site on base tables.
When refresh group job runs to refresh these MVs i got the errors
ORA-02292: integrity constraint (string.string) violated - child record found
After that job status has changed to break,but in the same time all the pending transactions at the MVs sites are pushed to Replication site i e ( Base tables at replication site and MVs of these tables are synchronized).In order to change the status of job to Normal, i have to disable some constraints(not all) on the MVs and manually run the job .After that job status will become Normal even i enable these constraints with validation.
What will be the reason ? Are there some MVs trying to complete refresh instead of Fast or increment refresh in this refresh group?If yes how i can trace out MVs and solve this problem?
Some other information , Replication site running with 10gR2 Enterprise Edition. Materialized View site running with 10gR2 Slandered Edition.
we have the following requirement for creating materialized view.
In database "DB1", a table "abc" is there in "user1" schema. In database "DB2", in "user2", we are accessing the "abc" through DB link "DBL1" to DB1: select * from user1.abc@DBL1; we have created a public synonym for "user1.abc@DBL1" as "sabc".
In database "DB3", we need to create the materialized view to access "abc" in DB1 through DB2. we are not allowed to access "DB1" directly from "DB3". so we create a db link as "DBL2" in "DB3" to "DB2".
when i try to create a materialized view as below: create materialized view abc_mv as select * from sabc@DBL2;
But got the error as "synonym translation invalid". When i access the SQL statement separately as below select * from sabc@DBL2, its working but in Materialized view, it shown that error. Even i tried with schema name as well like "user2.sabc@DBL2" , but that also thrown same error.
Is there any option available for this type of creating materialized view?
I am trying to create a commit on refresh materialized view so that whenever I perform DML followed by commit on Master table it should get quickly reflect on my Materialized view. I have given SELECT on table privilege to user where this view will be created On Master:
GRANT SELECT ON HR.EMPLOYEES TO SCOTT. From Scott:CREATE MATERIALIZED VIEW scott.hremp REFRESH FAST ON COMMITAS SELECT * FROM HR.EMPLOYEES; ERROR at line 4:ORA-01031: insufficient privileges Then I Grant all on EMPLOYEES table to SCOTT. GRANT ALL ON hr.EMPLOYEES TO SCOTT; Then got following error while creating materilized view:SQL> CREATE MATERIALIZED VIEW scott.hremp 2 REFRESH FAST ON COMMIT 3 AS 4 SELECT * FROM HR.EMPLOYEES;SELECT * FROM HR.EMPLOYEES *ERROR at line 4:ORA-23413: table "HR"."EMPLOYEES" does not have a materialized view log I create materialized view log on Master:SQL> CREATE MATERIALIZED VIEW LOG on HR.EMPLOYEES;Materialized view log created.
Even after this I am not able to create materialized view and now getting Table not Exist error:
SQL> CREATE MATERIALIZED VIEW scott.hremp 2 REFRESH FAST ON COMMIT 3 AS 4 SELECT * FROM HR.EMPLOYEES;SELECT * FROM HR.EMPLOYEES *ERROR at line 4:ORA-12018: following error encountered during code generation for "SCOTT"."HREMP"ORA-00942: table or view does not exist. Also I want to know why I needed to GRANT ALL to HR for creating this materialized View.
we are trying to create a materialized view (MV) which would access the remote database through db link. Now we need to do update on the local MV so that it should be reflected on the master table.
There is no primary key on this table and we are using "complete refresh" option. since we dont have control over remote database, we are not allowed to create MV log over there.
in this scenario, if i try to create updatetable MV with complete refresh, we are getting below error:
SQL Error: ORA-12013: updatable materialized views must be simple enough to do fast refresh
We have some materialized views in our environment which refreshes after every 1 hour. In the same environment, we have some big processes and we do not want the performance of these big processes to get affected because of refreshing these materialized views.
if there is a way to pause the refreshing of materialized views before running the big processes and later after the big processes are completed, then resume the refreshing of the materialized views?
One way I can think of is to drop the materialized views and create the materialized views back.
I am often tasked with refreshing schema's from one DB to another.The first thing I need to check is the space the objects take up in the source DB. SQL statement that prints the size of the following objects
I have a Multi layer Mviews and Views which i use to load a table. There are three base level Mview which is accessed by 4 views ... which are in turn accessed by a view which is used to load a table.
Before the insert called for the table .. the base mviews are refreshed.
I get the "ORA-01410 Invalid Rowid" error while inserting in to the table and while refreshing the mviews. They don't occur every time and not together as well.
The Mviews contains table joins and the top level views which accessing these mviews does aggregation. Below is the mview query for one of the mview.
I have a materialized view "pro_mview",I am trying to refresh the MVIEW by using the following statement.
EXEC DBMS_MVIEW.REFRESH('pro_mview','C');
But I am getting the below error.
* Error at line 1: ORA-12008: error in materialized view refresh path ORA-00942: table or view does not exist ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2256 ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2462 ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2431 ORA-06512: at line 1
I am able to fetch the data from that materialized view(pro_mview).
what would be the difference between a view and a materialized view? whether DML possible on a view? i think error occurs if DML tried on a view which is a combination of two or more tables, whether DML possible on a materialized view?
I have requirement to create materialized views. The design states to use Complete refresh. Now I am using WITH ROW_ID clause.
1. Question - what are the criteria to decide between WITH PRIMARY KEY & WITH ROW_ID clauses? I referred oracle doc, but couldn't exactly get this.
2. Background - The oracle doc mentions that - Primary key materialized views are the default type of materialized view. The master table must contain an enabled primary key constraint, and the defining query of the materialized view must specify all of the primary key columns directly.
Question - I saw some existing materialized views in my project using WITH PRIMARY KEY clause, but all of the primary key columns are not part of the Select query, but still these views are working fine, how is this possible?
3. Background - The oracle doc mentions that - Rowid materialized views must be based on a single table and cannot contain any of the following:
■Distinct or aggregate functions ■GROUP BY or CONNECT BY clauses ■Subqueries ■Joins ■Set operations
Question - But I have created a Rowid materialized view selecting data from more than one table & defining query involving outer joins. This materialized view got created & getting refreshed (complete refresh). But again this is contradicting with Oracle' statement.
We have a vendor-supplied 11g database where records are split between two schemas -- an ACTIVE schema and an ARCHIVE schema. Each object has both a corresponding object in both of the ACTIVE and ARCHIVE schemas.
The vendor also has a third schema where each object is merely a UNION ALL of the associated ACTIVE and ARCHIVE schema objects. For the sake of example, I'll call that schema COMBO.Over the years, we've created queries and reports that reference both the COMBO and ARCHIVE schemas and that has worked just fine.
The vendor has now set up a secondary database for us that we can use when the primary database is offline for patching/upgrades/etc. The trouble is, this secondary database only has the ACTIVE schema and records. The vendor will not be writing any ARCHIVE records to it.
Primary DB: ACTIVE, ARCHIVE, and COMBO schemas Secondary DB: only the ACTIVE schema.
is there a way to set up the missing ARCHIVE and COMBO schemas on the secondary DB such that we won't have to rewrite our SQL to accomodate the lack of an ARCHIVE schema when we move reports over to the backup database?
Of course, no records would need to be returned from the virtual ARCHIVE schema, but I'd love for the untouched SQL to run without error.
I have a report with 2 groups Gheader and Glines.The report looks at PO headers and lines. I want to create a data link from the the 2 queries based on the line id in po_lines_all.However I only want to select this in the lines query so I do not get repeating records at the header query.
i have created FAST refresh materialized view.it is eligible for FAST refresh because when i executed SELECT * FROM USER_MVIEWS i could see FAST_REFRESHABLE=DIRLOAD_DML and STALENESS=STALE and it is not getting refreshed(through DBA_JOBS). Why it is in STALE status and how to resolve it. and one of my materialized views is in NEEDS_COMPILE status
A scheduler job is there to refresh some materialized views. All the views are run under single job name. Some mviews are not refreshing and those are not refreshing in the next run too.if we run those mviews manually then they are working fine from then . after some days those views which i told before are not refreshing and this happens frequently and i check the job_run_details views also and i am not seeing any errors in that.