Updatable Materialized View with Union ALL
(please don't ask about db structure)
DB: 11gR2
create table table_1 (
id number primary key,
val varchar2(100)
create table table_2 (
id number primary key,
val varchar2(100)
insert into table_1(id) values (0);
insert into table_1(id) values (2);
insert into table_1(id) values (3);
insert into table_1(id) values (4);
insert into table_1(id) values (5);
insert into table_2(id) values (10);
insert into table_2(id) values (12);
insert into table_2(id) values (13);
insert into table_2(id) values (14);
insert into table_2(id) values (15);
update table_1 set val='Table1 val:'||id;
update table_2 set val='Table2 val:'||id;
create view v_table_all as
select * from table_1
view V_TABLE_ALL created.
select * from v_table_all;
ID VAL
0 Table1 val:0
2 Table1 val:2
3 Table1 val:3
4 Table1 val:4
5 Table1 val:5
select column_name, updatable, insertable, deletable
from user_updatable_columns
where table_name = 'V_TABLE_ALL'
COLUMN_NAME UPDATABLE INSERTABLE DELETABLE
ID YES YES YES
VAL YES YES YES
update v_table_all set val='XXX changed' where id = 3;
1 row updated.
select * from table_1;
ID VAL
0 Table1 val:0
2 Table1 val:2
3 XXX changed
4 Table1 val:4
5 Table1 val:5
rollback;
select * from table_1;
ID VAL
0 Table1 val:0
2 Table1 val:2
3 Table1 val:3
4 Table1 val:4
5 Table1 val:5
create or replace view v_table_all as
select * from table_1
union select * from table_2;
view V_TABLE_ALL created.
select * from v_table_all;
ID VAL
0 Table1 val:0
2 Table1 val:2
3 Table1 val:3
4 Table1 val:4
5 Table1 val:5
10 Table2 val:10
12 Table2 val:12
13 Table2 val:13
14 Table2 val:14
15 Table2 val:15
select column_name, updatable, insertable, deletable
from user_updatable_columns
where table_name = 'V_TABLE_ALL'
COLUMN_NAME UPDATABLE INSERTABLE DELETABLE
ID NO NO NO
VAL NO NO NO
trying update:
update v_table_all set val='XXX changed' where id = 3;
SQL-Fehler: ORA-01732: Datenmanipulationsoperation auf dieser View nicht zulässig
01732. 00000 - "data manipulation operation not legal on this view"
*Cause:
*Action:
drop view v_table_all;
view V_TABLE_ALL dropped.all is ok before this point.
now we want create a new materialized view with some query
create materialized view v_table_all
as
select * from table_1
union all select * from table_2 ;
materialized view V_TABLE_ALL created.
select column_name, updatable, insertable, deletable
from user_updatable_columns
where table_name = 'V_TABLE_ALL'
COLUMN_NAME UPDATABLE INSERTABLE DELETABLE
ID YES YES YES
VAL YES YES YES it seems to be ok with update.
but...
update v_table_all set val='XXX changed' where id = 3;
SQL-Fehler: ORA-01732: Datenmanipulationsoperation auf dieser View nicht zulässig
01732. 00000 - "data manipulation operation not legal on this view"
*Cause:
*Action:How can solve this issue??
Any suggestion
Looks like user_updatable_columns sort of thinks the MV is just a table - I don't know about that...
An MV on a single table can be updated - I tried that and it works:
create materialized view mv_table_1 for update
as
select * from table_1;I noticed [url http://download.oracle.com/docs/cd/E11882_01/server.112/e16579/advmv.htm#sthref294]examples stating the UNION ALL needs a "marker" so Oracle can know from the data which source table a row in the MV originates from - like this:
create materialized view v_table_all for update
as
select 'T1' tab_id, table_1.* from table_1
union all
select 'T2' tab_id, table_2.* from table_2 ;But that also fails (the "marker" requirement was specifically for FAST REFRESH, so it was just a long shot ;-) )
What are you planning to do?
<li>Create the MV.
<li>Update records in the MV - which then is no longer consistent with the source data.
<li>Schedule a complete refresh once in a while - thereby overwriting/losing the updates in the MV.
If that is the case, I suggest using a true table rather than an MV.
<li>Create table t_table_all as select ... .
<li>Update records in the table - which then is no longer consistent with the source data.
<li>Schedule a job to delete table and insert into table select ... once in a while - thereby overwriting/losing the updates in the table.
In other words a kind of "do it yourself MV".
I cannot see another way at the moment? But perhaps try in the data warehousing forum - the people there may have greater experience with MV's ;-)
Similar Messages
-
Materalized view with union all and fast referesh
I have a one view which is very slow. in this view we are joining many tables and many union all queries.
now I am planing to make materalized view
Tell me how i will created view with fast refresh with union all query.
Pls help its urgent..
Thanks
ReenaRefer to the Replication Manual for the create syntax and exceptions.
-
Report which concatenates 13 views with union all running slowly
Oracle 8.1.7 windows 2000 server
I am trying to improve the performance of a report which is comprised of 13 views.
When I run each of the views individually, the total run time for the views is less than 5 minutes. When I run the report, it takes 28 minutes.
Can anyone suggest why the extra time is being taken?
To reiterate:
select a,b from c; (executes in 10 seconds)
select d, e from f (executes in 3 seconds)
select x, y from z (executes in 1 minute)
total runs time = 5 minutes
However,
select a,b from c
union all
select d, e from f
union all
select x, y from z (executes in 28 minutes)
The execution plans do not change between the report and the indiividual views. Views are being concatenated with union all so no sorting is taking place
Many thanks,
Jason Parker.
Edited by: jclparker on Feb 18, 2009 4:26 AM
Edited by: jclparker on Feb 18, 2009 4:30 AMCould you post the execution plan? Please use formatting tags to save the white space while posting the plan.
-
Inconsistent SQL results when using View with UNION-ALL and table function
Can any of you please execute the below scripts and check the output. In the table type variable, I am adding 4 distinct object ids, where as in the result, I get only the row pertaining to last id in the table type variable. Same row is returned 4 times (4= number of values in the table type).
This scenario is occurring in our product with a SQL with exactly same pattern. I could simulate the same issue with the sample script I have provided.
Database version: 11.2.0.3 Enterprise Edition, Single node
Thank you.
CREATE TABLE TEMP_T1 AS SELECT * FROM ALL_OBJECTS;
CREATE TABLE TEMP_T2 AS SELECT * FROM ALL_OBJECTS;
UPDATE TEMP_T2 SET OBJECT_ID = OBJECT_ID * 37;
CREATE UNIQUE INDEX TEMP_T1_U1 ON TEMP_T1(OBJECT_ID);
CREATE UNIQUE INDEX TEMP_T2_U1 ON TEMP_T2(OBJECT_ID);
CREATE OR REPLACE VIEW TEMP_T1T2_V AS
SELECT * FROM TEMP_T1 UNION ALL SELECT * FROM TEMP_T2;
CREATE OR REPLACE TYPE TEMP_OBJ_TYPE AS OBJECT (OBJ_ID NUMBER);
CREATE OR REPLACE TYPE TEMP_OBJ_TAB_TYPE IS TABLE OF TEMP_OBJ_TYPE;
SET SERVEROUTPUT ON;
DECLARE
TYPE TEMP_T1T2_V_ROW_TAB_TYPE IS TABLE OF TEMP_T1T2_V%ROWTYPE;
TEMP_T1T2_V_ROW_TAB TEMP_T1T2_V_ROW_TAB_TYPE;
TEMP_OBJ_TAB TEMP_OBJ_TAB_TYPE := TEMP_OBJ_TAB_TYPE();
PROCEDURE ADD_TO_TEMP_OBJ_TAB(OBJ_ID IN NUMBER) IS
BEGIN
TEMP_OBJ_TAB.EXTEND;
TEMP_OBJ_TAB(TEMP_OBJ_TAB.LAST) := TEMP_OBJ_TYPE(OBJ_ID);
END;
BEGIN
ADD_TO_TEMP_OBJ_TAB(100);
ADD_TO_TEMP_OBJ_TAB(116);
ADD_TO_TEMP_OBJ_TAB(279);
ADD_TO_TEMP_OBJ_TAB(364);
DBMS_OUTPUT.PUT_LINE('=====================');
FOR I IN TEMP_OBJ_TAB.FIRST..TEMP_OBJ_TAB.LAST
LOOP
DBMS_OUTPUT.PUT_LINE('OBJ_ID = '||TEMP_OBJ_TAB(I).OBJ_ID);
END LOOP;
DBMS_OUTPUT.PUT_LINE('---------------------');
SELECT * BULK COLLECT INTO TEMP_T1T2_V_ROW_TAB
FROM TEMP_T1T2_V VW
WHERE ((VW.OBJECT_ID) IN (SELECT OBJ_ID
FROM TABLE(CAST(TEMP_OBJ_TAB AS TEMP_OBJ_TAB_TYPE))));
FOR I IN TEMP_OBJ_TAB.FIRST..TEMP_OBJ_TAB.LAST
LOOP
DBMS_OUTPUT.PUT_LINE('OBJ_ID = '||TEMP_OBJ_TAB(I).OBJ_ID);
END LOOP;
DBMS_OUTPUT.PUT_LINE('---------------------');
IF TEMP_T1T2_V_ROW_TAB.COUNT > 0 THEN
FOR I IN TEMP_T1T2_V_ROW_TAB.FIRST..TEMP_T1T2_V_ROW_TAB.LAST
LOOP
DBMS_OUTPUT.PUT_LINE(TEMP_T1T2_V_ROW_TAB(I).OBJECT_ID||' : '||TEMP_T1T2_V_ROW_TAB(I).OBJECT_NAME);
END LOOP;
ELSE
DBMS_OUTPUT.PUT_LINE('NO ROWS RETURNED!');
END IF;
DBMS_OUTPUT.PUT_LINE('---------------------');
END;
/I can reproduce it:
SQL*Plus: Release 11.2.0.3.0 Production on Tue Oct 30 14:05:39 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Enter user-name: scott
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select *
2 from v$version
3 /
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for 64-bit Windows: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
SQL> CREATE TABLE TEMP_T1 AS SELECT * FROM ALL_OBJECTS;
Table created.
SQL>
SQL> CREATE TABLE TEMP_T2 AS SELECT * FROM ALL_OBJECTS;
Table created.
SQL>
SQL> UPDATE TEMP_T2 SET OBJECT_ID = OBJECT_ID * 37;
72883 rows updated.
SQL>
SQL> CREATE UNIQUE INDEX TEMP_T1_U1 ON TEMP_T1(OBJECT_ID);
Index created.
SQL>
SQL> CREATE UNIQUE INDEX TEMP_T2_U1 ON TEMP_T2(OBJECT_ID);
Index created.
SQL>
SQL> CREATE OR REPLACE VIEW TEMP_T1T2_V AS
2 SELECT * FROM TEMP_T1 UNION ALL SELECT * FROM TEMP_T2;
View created.
SQL>
SQL> CREATE OR REPLACE TYPE TEMP_OBJ_TYPE AS OBJECT (OBJ_ID NUMBER)
2 /
Type created.
SQL> CREATE OR REPLACE TYPE TEMP_OBJ_TAB_TYPE IS TABLE OF TEMP_OBJ_TYPE
2 /
Type created.
SQL> SET SERVEROUTPUT ON;
SQL>
SQL> DECLARE
2 TYPE TEMP_T1T2_V_ROW_TAB_TYPE IS TABLE OF TEMP_T1T2_V%ROWTYPE;
3 TEMP_T1T2_V_ROW_TAB TEMP_T1T2_V_ROW_TAB_TYPE;
4 TEMP_OBJ_TAB TEMP_OBJ_TAB_TYPE := TEMP_OBJ_TAB_TYPE();
5 PROCEDURE ADD_TO_TEMP_OBJ_TAB(OBJ_ID IN NUMBER) IS
6 BEGIN
7 TEMP_OBJ_TAB.EXTEND;
8 TEMP_OBJ_TAB(TEMP_OBJ_TAB.LAST) := TEMP_OBJ_TYPE(OBJ_ID);
9 END;
10 BEGIN
11 ADD_TO_TEMP_OBJ_TAB(100);
12 ADD_TO_TEMP_OBJ_TAB(116);
13 ADD_TO_TEMP_OBJ_TAB(279);
14 ADD_TO_TEMP_OBJ_TAB(364);
15 DBMS_OUTPUT.PUT_LINE('=====================');
16 FOR I IN TEMP_OBJ_TAB.FIRST..TEMP_OBJ_TAB.LAST
17 LOOP
18 DBMS_OUTPUT.PUT_LINE('OBJ_ID = '||TEMP_OBJ_TAB(I).OBJ_ID);
19 END LOOP;
20 DBMS_OUTPUT.PUT_LINE('---------------------');
21 SELECT * BULK COLLECT INTO TEMP_T1T2_V_ROW_TAB
22 FROM TEMP_T1T2_V VW
23 WHERE ((VW.OBJECT_ID) IN (SELECT OBJ_ID
24 FROM TABLE(CAST(TEMP_OBJ_TAB AS TEMP_OBJ_TAB_TYPE))));
25 FOR I IN TEMP_OBJ_TAB.FIRST..TEMP_OBJ_TAB.LAST
26 LOOP
27 DBMS_OUTPUT.PUT_LINE('OBJ_ID = '||TEMP_OBJ_TAB(I).OBJ_ID);
28 END LOOP;
29 DBMS_OUTPUT.PUT_LINE('---------------------');
30 IF TEMP_T1T2_V_ROW_TAB.COUNT > 0 THEN
31 FOR I IN TEMP_T1T2_V_ROW_TAB.FIRST..TEMP_T1T2_V_ROW_TAB.LAST
32 LOOP
33 DBMS_OUTPUT.PUT_LINE(TEMP_T1T2_V_ROW_TAB(I).OBJECT_ID||' : '||TEMP_T1T2_V_ROW_TAB(I).OBJECT_NAME);
34 END LOOP;
35 ELSE
36 DBMS_OUTPUT.PUT_LINE('NO ROWS RETURNED!');
37 END IF;
38 DBMS_OUTPUT.PUT_LINE('---------------------');
39 END;
40 /
=====================
OBJ_ID = 100
OBJ_ID = 116
OBJ_ID = 279
OBJ_ID = 364
OBJ_ID = 100
OBJ_ID = 116
OBJ_ID = 279
OBJ_ID = 364
364 : I_AUDIT
364 : I_AUDIT
364 : I_AUDIT
364 : I_AUDIT
PL/SQL procedure successfully completed.
SQL> column object_name format a30
SQL> select object_id,
2 object_name
3 from dba_objects
4 where object_id in (100,116,279,364)
5 /
OBJECT_ID OBJECT_NAME
100 ORA$BASE
116 DUAL
279 MAP_OBJECT
364 I_AUDIT
SQL> Works fine in:
=====================
OBJ_ID = 100
OBJ_ID = 116
OBJ_ID = 279
OBJ_ID = 364
OBJ_ID = 100
OBJ_ID = 116
OBJ_ID = 279
OBJ_ID = 364
100 : ORA$BASE
116 : DUAL
364 : SYSTEM_PRIVILEGE_MAP
279 : MAP_OBJECT
PL/SQL procedure successfully completed.
SQL> select object_id,
2 object_name
3 from dba_objects
4 where object_id in (100,116,279,364)
5 /
OBJECT_ID OBJECT_NAME
100 ORA$BASE
116 DUAL
364 SYSTEM_PRIVILEGE_MAP
279 MAP_OBJECT
SQL> select *
2 from v$version
3 /
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL>SY.
Edited by: Solomon Yakobson on Oct 30, 2012 2:14 PM -
Oracle doc inconsistent on materialize view with union all and self joins
First of all, I can't seem to create a materialized view containing self-joins AND union all. Is it possible?
I checked Oracle 9i (my version: PL/SQL Release 9.2.0.4.0 - Production) documentation and I get different answers (or so it seems to me).
First I saw this: "The COMPATIBILITY parameter must be set to 9.0 if the materialized aggregate view has inline views, outer joins, self joins or grouping sets and FAST REFRESH is specified during creation..."
Did you see the part about 'self joins' in there? I did and I was pumped because that seems to say that you CAN have 'self joins' (and my compatibility is 9.2...)
BUT
In the very same document I also found "Oracle does not allow self-joins in materialized join views." (rage)
You can see the document I am speaking of here: http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96520/mv.htm#574889
Whenever I try to create the mview I get the following error. (
In any caseORA-01446 cannot select ROWID from view with DISTINCT, GROUP BY, etc.First of all, I can't seem to create a materialized view containing self-joins AND union all. Is it possible?
I checked Oracle 9i (my version: PL/SQL Release 9.2.0.4.0 - Production) documentation and I get different answers (or so it seems to me).
First I saw this: "The COMPATIBILITY parameter must be set to 9.0 if the materialized aggregate view has inline views, outer joins, self joins or grouping sets and FAST REFRESH is specified during creation..."
Did you see the part about 'self joins' in there? I did and I was pumped because that seems to say that you CAN have 'self joins' (and my compatibility is 9.2...)
BUT
In the very same document I also found "Oracle does not allow self-joins in materialized join views." (rage)
You can see the document I am speaking of here: http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96520/mv.htm#574889
Whenever I try to create the mview I get the following error. (
In any caseORA-01446 cannot select ROWID from view with DISTINCT, GROUP BY, etc. -
Error creating materilalized view with union all
Could please anybody advice? What I do wrong?
create table test
i number not null,
constraint pk_test primary key( i ));
create materialized view log on test with rowid;
create materialized view mvtest refresh fast on demand as
SELECT i, 1 umarker FROM test where i < 10000
UNION ALL SELECT i, 2 umarker FROM test where i > 10000;
ORA-12052: cannot fast refresh materialized view MVTEST
It looks like I accomplished all fast refresh requirements, didn't I?
Thanks a lot.
Alexander.SQL> create table test
2 (i number not null,
3 constraint pk_test primary key( i ));
Table created.
SQL> create materialized view log on test with rowid;
Materialized view log created.
SQL> create materialized view mvtest refresh fast on demand as
2 SELECT t.i, 1 umarker, t.rowid row_id FROM test t where t.i <= 10000
3 UNION ALL
4 SELECT t.i, 2 umarker, t.rowid row_id FROM test t where t.i > 10000;
Materialized view created.(This is on 11.2) -
Different results using View with union all in 11R1 compared to 10R2
Hello,
I have the following situation:
In Oracle 10R2 I defined a view which looks like this
create view test_view
as
select 'field1;field2;field3' field from dual
union all
select field
from (
select tfield1||';'||tfield2||';'||tfield3 field
from table1
order by tfield1,tfield2,tfield3
The idea is, my first line contains a header information an then the data in the required sorting order.
So, in 10R2, when I export the view with select field from test_view, I get the result as expected, which means, the header from the part with the dual was in the first line and after that, the data in the required sort order.
Now, in 11.1.0.7, it is completely different, because the row of the dual is somewhere in my result set. But if I send the sql instead of the view, I get the expected result as in 10R2.
I have no idea why this is the case now, because in 10R2 this was working permanently as expected. When I look at the execution plan, I see, that he starts parallelisation, which is ok, but the difference is, that in this parallelisation the select from dual is included and in 10R2 he first make the line from the dual and then the parallelisation with the data. It's not clear to me, that if I send the sql to the database I see the required result, but if i define the view as mentioned, and start a select field from view, I get now get the different sorting, because of the parallelisation, where the optimizer he changes his behavior comparing the both database versions. So my question ist, how can I change this behavior to get the same behavior as in release 10R2.
Best regards
RainerHello,
thank you for your sample, I see your idea for my sorting purpose.
I want to look at the following point:
I create the table, as you described. The table has the degree and instances 1. Now I deefine the following view:
create view view_test
as
select 'field1;field2;field3' field
from dual
union all
select tfield1 || ';' || tfield2 || ';' || tfield3 field
from (select * from table1 order by tfield1,tfield2).
This is the way I used it in 10 R2.
Now, the SQL select field from view_test delivers the expected result:
field1;field2;field3
a;b;c
d;e;f
So far so good. But now, I changed the degree of the table1 (alter table table1 parallel (degree 4 instances 1);).
The result looks like that:
a;b;c
field1;field2;field3
d;e;f
So, the parallelisation of my object seems to be the reason for the, in my eyes, "wrong" sort order. In 10R2 I used this degree and instance values for my table and defined a view and it was working fine. Now, after our migration, I had this "trouble". For me it seems, that the optimizer made some changes, or mabe this is a bug, who knows ?
I also tried, to change the nls_comp, and set the undocumented parameters as described in the Metalink note 7497640.8, but with no effect of my result set.
Best regards
Rainer -
Dear Dev/DBAs,
I have the following scenario:
SQL> CREATE TABLE T1 (ID NUMBER(3),NAME VARCHAR2(10));
SQL> CREATE TABLE T2 (ID NUMBER(3),NAME VARCHAR2(10));
The T1 contains records having the ID num from 10 to 80 and the T2 having the ID from 90 to 170
SQL> SELECT * FROM T1 JOIN ALL SELECT * FROM T2
It give all records in the 2 tables.
I'm planning to create a materialized view (like CREATE MATERIALIZED VIEW V_TAB REFRESH ON COMMIT AS SELECT * FROM T1 JOIN ALL SELECT * FROM T2) and it seems i can't do with the error ORA-12054, further the oracle documentation says that materialized view can only be used with a simple join.
Do you have another solution??
Note that the materialized views can be used to improve queries.
Thank you in advanceStraight from the link I posted:
*Restrictions on Fast Refresh on Materialized Views with UNION ALL*Materialized views with the UNION ALL set operator support the REFRESH FAST option if the following conditions are satisfied:
* The defining query must have the UNION ALL operator at the top level.
The UNION ALL operator cannot be embedded inside a subquery, with one exception: The UNION ALL can be in a subquery in the FROM clause provided the defining query is of the form SELECT * FROM (view or subquery with UNION ALL) as in the following example:
CREATE VIEW view_with_unionall AS
(SELECT c.rowid crid, c.cust_id, 2 umarker
FROM customers c WHERE c.cust_last_name = 'Smith'
UNION ALL
SELECT c.rowid crid, c.cust_id, 3 umarker
FROM customers c WHERE c.cust_last_name = 'Jones');
CREATE MATERIALIZED VIEW unionall_inside_view_mv
REFRESH FAST ON DEMAND AS
SELECT * FROM view_with_unionall;
Note that the view view_with_unionall satisfies the requirements for fast refresh.
* Each query block in the UNION ALL query must satisfy the requirements of a fast refreshable materialized view with aggregates or a fast refreshable materialized view with joins.
The appropriate materialized view logs must be created on the tables as required for the corresponding type of fast refreshable materialized view.
Note that the Oracle Database also allows the special case of a single table materialized view with joins only provided the ROWID column has been included in the SELECT list and in the materialized view log. This is shown in the defining query of the view view_with_unionall.
* The SELECT list of each query must include a maintenance column, called a UNION ALL marker. The UNION ALL column must have a distinct constant numeric or string value in each UNION ALL branch. Further, the marker column must appear in the same ordinal position in the SELECT list of each query block.
* Some features such as outer joins, insert-only aggregate materialized view queries and remote tables are not supported for materialized views with UNION ALL.
* Partiton Change Tracking (PCT)-based refresh is not supported for UNION ALL materialized views.
* The compatibility initialization parameter must be set to 9.2.0 or higher to create a fast refreshable materialized view with UNION ALL. -
Updatable materialized view- error with CREATE_SNAPSHOT_REPGROUP
I'm trying to create an updatable materialized view from the replication administrators account (REPADMIN). I use the assistant and in the third step (after creating the replication group and the materialized view), when the materialized view is going to be added to the group, I got this error:
ERROR in line 1:
ORA-01403: No data found
ORA-06512: in "SYS.DBMS_REPCAT_SNA_UTL", line 5927
ORA-06512: in "SYS.DBMS_REPCAT_SNA", line 82
ORA-06512: in "SYS.DBMS_REPCAT", line 1332
ORA-06512: in "SYS.DBMS_REPCAT", line 1307
ORA-06512: in line 2
I have also tried to use the command file that the assistant generates (I add below), and the error is triggered within the CREATE_SNAPSHOT_REPOBJECT procedure.
Has anybody any idea to resolve the problem?
Thanks in advance
BEGIN
DBMS_REPCAT.CREATE_SNAPSHOT_REPGROUP(
gname => '"MYGROUP"',
master => 'DB.DOMAIN.COM',
propagation_mode => 'ASYNCHRONOUS');
END;
CREATE SNAPSHOT "MYUSER"."MYTABLE"
REFRESH COMPLETE WITH ROWID
FOR UPDATE
AS SELECT "COD", "NAME" FROM
"MYUSER"."MYTABLE"@DB.DOMAIN.COM c
BEGIN
DBMS_REFRESH.ADD(
name => '"MYUSER"."REF3"',
list => '"MYUSER"."MYTABLE"',
lax => TRUE);
END;
BEGIN
DBMS_REPCAT.CREATE_SNAPSHOT_REPOBJECT(
gname => '"MYGROUP"',
sname => '"MYUSER"',
oname => '"MYTABLE"',
type => 'SNAPSHOT',
min_communication => FALSE);
END;Hello,
These days I have had some problems with my forum-account and I haven't been able to connect and reply.
Regarding to your doubt, the name of refresh group was correct, and as I see, the problem can't be related to the refresh group.
While the problem with my account was resolved, I created two new databases (*) and the problem within the materialized view process is disappeared. I suppose that my first original databases were degraded, but I don't know where.
(*) of course, I could do that because I use Oracle in an academy institution, not for production, thank God
Anyway, for now I will give up here. Thanks for your help.
Regards, -
In 10g release 2,I tried to create following materialized view with join:
test_link is a normal table
test_geom is a table contains a column in SDO_GEOMETRY
CREATE MATERIALIZED VIEW LOG ON test_link with rowid
CREATE MATERIALIZED VIEW LOG ON test_geom with rowid,primary key
CREATE MATERIALIZED VIEW MV_LINK USING INDEX REFRESH FAST ON DEMAND AS
SELECT li.rowid link_rowid,geom.rowid geom_rowid,li.link_id,geom.link
FROM test_link li, test_geom geom
WHERE li.link_id=geom.link_id
But I always got an error like:
ORA-12015: cannot create a fast refresh materialized view from a complex query
If I change the geometry table to another table, everything works fine.
Anyone have ideas?Unfortunately, creating a fast refreshable materialized view on a join with one of the select columns being a user defined type (sdo_geometry is a user defined type) is not allowed. See 5303489 in the metalink bug database.
You could do like the workaround in the article suggests and create two materialized views and then create a regular view on top.
In our scenario, our materialized view also contains unions, so we would really like to have one physical object at the end of the day. One approach that we are currently investigating is to create the materialized view (MV1) without the geometry column, which makes it fast refreshable, and also create a materialized view (MV2) on the table containing the geometry column. MV2 is also fast refreshable. We then create a table (T3) that contains all of the columns from MV1, plus a geometry column. An insert, update, delete trigger on MV1 is created. The trigger is used to push all of the columns from MV1 to T3 and the geometry column from MV2 to T3. I have created the above in one of our test environments and haven't encountered any issues yet.
Let me know if you come up with a better approach. -
Materialized View with Sequence
Please help!!
I was wondering if anyone knows how to create a MATERIALIZED VIEW with a generating sequence number (sequence.nextval)???
This is sort of what I want but it doesn't work:
create materialized view ORACLE_AUDIT_LOG_MVW
refresh force start with sysdate
next sysdate + 1
with primary key
as select oracle_seq.nextval,
'Auditing Information' title,
ses.tnsname,
o.obj_owner,
o.obj_name,
o.action_name,
ses.os_username,
ses.username,
ses.machine as machine,
ses.program,
ses.module,
ses.client_ip,
ses.connection_msg,
to_char(ses.logon_time,'DD-MON-YY HH:MM:SS'),
to_char(ses.logoff_time,'DD-MON-YY HH:MM:SS')
from audit_sessions ses, audit_objects o
where ses.tnsname = o.tnsname
and ses.sessionid = o.sessionid
GROUP BY ses.tnsname, O.SESSIONID, o.obj_owner, o.obj_name, o.action_name, ses.os_username, ses.username, ses.machine, ses.program, ses.module, ses.client_ip, ses.connection_msg, ses.logon_time, ses.logoff_time
UNION all
select oracle_seq.nextval,
'Failed Logons' title,
fl.tnsname,
fl.os_username,
fl.username,
fl.terminal as terminal,
fl.connection_msg,
to_char(fl.logon_time,'DD-MON-YY HH:MM:SS'),
from audit_failed_logons fl
Can someone PPPLLLLEEEAAAASSSEE help me???
Thanks so much,
Mary LeeFirst, "doesn't work" isn't particularly descriptive. Error numbers and error messages would be very helpful.
Second, does it have to be a sequence value? Could you not use either ROWNUM or one of the analytic functions (RANK, DENSE_RANK, ROW_NUMBER, etc)?
Third, you'll almost certainly need this MV to be completely refreshed every time...
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
ORA-01446 when selecting ROWID from View with Union
I have a View that uses a Union to select from 3 tables. I would like the View to return the ROWID for the record that is returned so that I can update it in my form. The View compiles fine but when I select from the View I get ORA-01446 error.
Example of my view:
SELECT ROWID, col_a, col_b, col_c
FROM tab_a
UNION ALL
SELECT ROWID, col_a, col_b, col_c
FROM tab_b
UNION ALL
SELECT ROWID, col_a, col_b, col_c
FROM tab_c
I need the ROWID because my tables do not contain UNIQUE/PRIMARY key constraints. In my form I want to update the view with an underlying INSTEAD OF database trigger.
Any suggestions?I think it will work if you give the column an alias (ie a name after the first rowid) and select that instead.
You will probably also need another column in your view indicating which table the row came from if you want to update it. -
Scheduling updatable materialized view
Hi everybody,
As you may know I have a solution in which I have 5 sites .One master site with 4 updatable materialized view sites.
I want to know that is it correct if I dont set up schedule push to run periodically and set it up to do continuous push ?
I want in at least 2 minutes all sites become update and I have to mention that at first I tried multimaster but our client doesn't want that because they want if one special site becomes unavailable they others can not transfer data to eachother.
I appreciate your help in advance.Your requirements are a bit unclear...
1) In general, if you are looking to have sites updated within a minute or two of the original transaction being committed, you are better off looking at something like Streams rather than using materialized views.
2) Architecturally, when you set up multi-master replication (which it sounds like you are attempting to do here), you need to choose between synchronous and asynchronous replication. Synchronous replication means that a transaction cannot commit until it has been pushed to all the other nodes, which is great for latency but horrible for performance, scalability, and availability. Very, very few people really want synchronous replication. That leaves asynchronous replication, which would require you to schedule jobs to replicate changes. Some folks who think they want asnychronous replication really want another technology entirely (i.e. DataGuard, RAC, etc).
3) Are you sure about the requirement "they want if one special site becomes unavailable they others can not transfer data to each other"? That says that if one site fails, they want all transactions everywhere to fail. That pretty much defeats the purpose of setting up multi-master replication. If the system is only available as long as every node is available, and you're going to incur the overhead of synchronous replication on every change, you would be far better served consolidating everything into a single data center and potentially using RAC to create a multi-node cluster to spread the work among nodes. There would be very little benefit to offset the complexity of configuring and maintaining a multi-master replication environment if you didn't want the nodes to be able to continue in the event that one of them failed.
Justin -
Create materialized view with specific column sizes
Hi all,
I'm trying to create a materialized view with a specific a column size. Something like
create materialized view test_mv
refresh force on demand
as
select id,
cast(my_compound_field as nvarchar2(50))
from ( select id,
field1 || field2 my_compound_field
from my_table);But Oracle seems to ignore the cast and takes the maximum size it finds for field1 || field2 in the select query. The resulting table has a column nvarchar2(44) instead of nvarchar2(50).
This can give a problem when the view is refreshed... there could be new data that exceeds the current size, i.e. where length(field1 || field2) > 44.
How can I override the column size of a field in a materialized view?
Edit: Some additional info to clarify my case:
field1 and field2 are defined as nvarchar2(25). field1 || field2 can theoretically have a length of 50, but there is currently no data in my table that results in that length, the max is 44. I am afraid that there will be data in the future that exceeds 44, resulting in an error when the MV is refreshed!
Edited by: Pleiadian on Jan 25, 2011 2:06 PMCannot reproduce what you are saying is happening.
SQL> create table t (a nvarchar2(50), b nvarchar2(50));
Table created.
SQL> create materialized view tmv as
2 select a, b, a || b c from t;
Materialized view created.
SQL> desc tmv
Name Null? Type
A NVARCHAR2(50)
B NVARCHAR2(50)
C NVARCHAR2(100)
SQL> drop materialized view tmv;
Materialized view dropped.
SQL> create materialized view tmv as
2 select a, b, substr(a || b, 1, 10) c from t;
Materialized view created.
SQL> desc tmv
Name Null? Type
A NVARCHAR2(50)
B NVARCHAR2(50)
C NVARCHAR2(10)
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for Linux: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production
SQL>Edited by: 3360 on Jan 25, 2011 8:10 AM
And with data
SQL> insert into t values ('3123423423143hhshgvcdcvw', 'ydgeew gdfwe dfefde wfjjjjjjj');
1 row created.
SQL> commit;
Commit complete.
SQL> desc tmv
Name Null? Type
A NVARCHAR2(50)
B NVARCHAR2(50)
C NVARCHAR2(10)
SQL> select * from tmv;
A
B C
3123423423143hhshgvcdcvw
ydgeew gdfwe dfefde wfjjjjjjj 3123423423 -
How to create materialized view with parameter and index ?
Hi all,
i am using oracle 11g.
i want to create parameter materialized view with two parameter (STORED_VALUE, LOV_NAME) with an index .
i have below view
CREATE OR REPLACE FORCE VIEW SR_MY_TEST(DISPLAYED_VALUE, STORED_VALUE, LOV_NAME) AS
SELECT DISPLAYED_VALUE , LOVVALUE.STORED_VALUE , lovname.lov_name
FROM (SELECT T.LOV_VALUE_ID,
T.LOV_ID,
T.ORG_ENTITY_ID,
T.STORED_VALUE,
T.DISPLAYED_VALUE,
T.ENTERPRISE_ID
FROM MS_QS_LIST_OF_VALUES_T T) lovvalue, ms_qs_lov_names lovname
WHERE lovvalue.lov_id = lovname.lov_id
AND lovvalue.org_entity_id = 1
and LOVVALUE.ENTERPRISE_ID = 100000
AND LOVNAME.ENTERPRISE_ID = 100000;
i want to create index on STORED_VALUE, LOV_NAME
Thanks
DambyNo.AFAIK, there's nothing called as "parameterized MV".
Materialized View store data like tables (and not like Views). So, does it make sense when you say - "table with parameters" ?
Could you please explain your business requirement?
What is the purpose behind those 2 parameters?
Maybe you are looking for
-
I have several projects ive developed with FB 4.6 on winxp. I purchased a new win8 pc since the old pc began to fail, and purchased FB 4.7 64bit for my win8 pc, I only wanted the serial which i presumed i could use to register FB 4.6, which you cant
-
HT1766 how to enable my iphone?
suddenly i forget my iphone pass word and i try to enter the pass code it was wrong and make my iphone disabled so do i enable my iphonr
-
Epson RX595 and Jabra a320s Bluetooth adapter?
Hi all, Just a quick question. I have an RX595 currently connected to my Time Capsule, and seeing as it is giving me difficulty with a Vista laptop (printing multiple copies of same job) I was looking into other connectivity options that don't includ
-
Error in the tutorial OnlineInteractiveForm
Hi, i´m doing this tutorial that use Adobe Service, i download de program complete for see the application, but when i execute, appear this error: com.sap.tc.webdynpro.pdfobject.core.PDFObjectRuntimeException: Processing exception during a "Usage
-
Network Performance Troubleshooting?
Greetings all, I have a new Sun X4240 server installed as an enterprise backup media server and it's suffering terrible network performance to our new Exagrid disk storage backup appliance. The shares on the Exagrid are mounted as NFS3 shares on the