暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle MVIEW依赖关系

askTom 2016-08-05
186

问题描述

MVIEW依赖关系存储在哪里?

SQL> 将视图y1创建为从dual中选择1作为y1;

视图创建。

SQL> create materialized view y2 as select y1 as y2 from y1;

Materialized view created.

SQL> create view y3 as select y2 as y3 from y2;

视图创建。

SQL> select name, type, referenced_name, referenced_type from user_dependencies where name like 'Y%';

NAME       TYPE                 REFERENCED REFERENCED_TYPE
---------- -------------------- ---------- --------------------
Y1         VIEW                 DUAL       SYNONYM
Y2         MATERIALIZED VIEW    Y2         TABLE
Y3         VIEW                 Y2         TABLE


我可以看到Y3依赖于Y2,但是在哪里可以看到Y2依赖于Y1?

专家解答

有趣的是,如果Y1是一张表,事情似乎还可以,只是当它是一个视图时。

SQL> create view y1 as select 1 as c1 from dual;

View created.

SQL> create materialized view y2 as select c1 as c2 from y1;

Materialized view created.

SQL> create or replace view y3 as select c2 as c3 from y2;

View created.

SQL> select name, type, referenced_name, referenced_type from user_dependencies where name like 'Y%';

NAME                           TYPE               REFERENCED_NAME                REFERENCED_TYPE
------------------------------ ------------------ ------------------------------ ------------------------------
Y1                             VIEW               DUAL                           SYNONYM
Y2                             MATERIALIZED VIEW  Y2                             TABLE
Y3                             VIEW               Y2                             TABLE

3 rows selected.


SQL> create table y1 as select 1 as c1 from dual;

Table created.

SQL> create materialized view y2 as select c1 as c2 from y1;

Materialized view created.

SQL> create or replace view y3 as select c2 as c3 from y2;

View created.

SQL> select name, type, referenced_name, referenced_type from user_dependencies where name like 'Y%';

NAME                           TYPE               REFERENCED_NAME                REFERENCED_TYPE
------------------------------ ------------------ ------------------------------ ------------------------------
Y2                             MATERIALIZED VIEW  Y1                             TABLE
Y2                             MATERIALIZED VIEW  Y2                             TABLE
Y3                             VIEW               Y2                             TABLE

3 rows selected.

SQL>


我认为您需要支持,尽管xxx_DEPENDENCIES的文档不能保证 * 每个 * 对象将包含在那里:

“All_dependency描述了当前用户可以访问的过程,包,函数,包主体和触发器之间的依赖关系,包括对在没有任何数据库链接的情况下创建的视图的依赖关系”


「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论