A view depends on the base tables or views referenced in its defining query. If the
defining query of a view is not explicit about which columns are referenced, for
example, SELECT * FROM table, then the defining query is expanded when stored
in the data dictionary to include all columns in the referenced base table at that time.
If a base table or view of a view is altered, renamed, or dropped, then the view is
invalidated, but its definition remains in the data dictionary along with the privileges,
synonyms, other objects, and other views that reference the invalid view.
Note: Whenever you create a table, index, and view, and then drop
the table, all objects dependent on that table are invalidated, including
views, packages, package bodies, functions, and procedures.
An attempt to use an invalid view automatically causes Oracle to recompile the view
dynamically. After replacing the view, the view might be valid or invalid, depending
on the following conditions:
■ All base tables referenced by the defining query of a view must exist. If a base
table of a view is renamed or dropped, the view is invalidated and cannot be used.
References to invalid views cause the referencing statement to fail. The view can
be compiled only if the base table is renamed to its original name or the base table
is re-created.
■ If a base table is altered or re-created with the same columns, but the datatype of
one or more columns in the base table is changed, then most dependent views can
be recompiled successfully.
■ If a base table of a view is altered or re-created with at least the same set of
columns, then the view can be validated. The view cannot be validated if the base
table is re-created with new columns and the view references columns no longer
contained in the re-created table. The latter point is especially relevant in the case
of views defined with a SELECT * FROM table query, because the defining
query is expanded at view creation time and permanently stored in the data
dictionary.
视图和基表
[@more@]来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10599713/viewspace-983759/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10599713/viewspace-983759/
本文探讨了数据库中视图与基表之间的依赖关系。详细解释了当基表被修改、重命名或删除时,视图的有效性如何受到影响。此外还讨论了不同情况下视图能否重新编译及保持有效性的条件。
18

被折叠的 条评论
为什么被折叠?



