ORA-12015: cannot create a fast refresh materialized view from a complex query

http://inthirties.com:90/viewthread.jsp?tid=1380&frombbs=1

 

[oracle@solaris ~]oerr ora 12015
12015, 00000, “cannot create a fast refresh materialized view from a complex query”
// *Cause: Neither ROWIDs and nor primary key constraints are supported for
// complex queries.
// *Action: Reissue the command with the REFRESH FORCE or REFRESH COMPLETE
// option or create a simple materialized view.


在online redefinition里,start_redef_table的时候,提示上面的错误。online redef是基于materialized view的技术的,就如你看到的有的,有USE_PK和USE_ROWID一样,这些都是在我们在materialized view里经常看到的概念,这里一样,由于在transfer的过程中,无法准确应用mvlog从而导致专业的问题。

这里我这里出错的原因,就是在我加入了一个自己定义的function。

如下

SQL> exec dbms_redefinition.start_redef_table(’TEST’,'T’,'T_NEW’, ‘id, test.id2name(id) name’);
BEGIN dbms_redefinition.start_redef_table(’TEST’,'T’,'T_NEW’, ‘id, test.id2name(id) name’); END;

*
ERROR at line 1:
ORA-42008: error occurred while instantiating the redefinition
ORA-12015: cannot create a fast refresh materialized view from a complex query
ORA-06512: at “SYS.DBMS_REDEFINITION”, line 50
ORA-06512: at “SYS.DBMS_REDEFINITION”, line 1343
ORA-06512: at line 1

这里加了一个自己的function, id2name,
如下

create or replace function id2name(tid number) return varchar Deterministic is
rtnname varchar(4000);
begin
select object_name into rtnname from all_objects where object_id = tid;
return rtnname;
end;

这里在定义的地方加上Deterministic 即可。

  • 提供Oracle管理/故障处理/优化/安装/RAC/备份恢复技术服务,提供专业的Oracle培训和咨询服务。
  • 邮件: [email protected]
  • MSN: [email protected]
  • QQ: [email protected]
  • 电话: 13828706466
  • 技术博客 http://blog.csdn.net/inthirties
  • 个人站点 http://blog.inthirties.com

你可能感兴趣的:(oracle,object,function,table,query,constraints)