Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / Oracle selected docs / Database concepts.pdf
Скачиваний:
29
Добавлен:
12.05.2015
Размер:
6.96 Mб
Скачать

Views

SELECT last_name

FROM employees_view

WHERE employee_id = 9876;

The final query constructed by Oracle is:

SELECT last_name

FROM employees, departments

WHERE employees.department_id = departments.department_id AND departments.department_id = 10 AND employees.employee_id = 9876;

In all possible cases, Oracle merges a query against a view with the view’s defining query and those of any underlying views. Oracle optimizes the merged query as if you issued the query without referencing the views. Therefore, Oracle can use indexes on any referenced base table columns, whether the columns are referenced in the view definition or in the user query against the view.

In some cases, Oracle cannot merge the view definition with the user-issued query. In such cases, Oracle may not use all indexes on referenced columns.

See Also: Oracle9i Database Performance Tuning Guide and Reference for more information about query optimization

Dependencies and Views

Because a view is defined by a query that references other objects (tables, materialized views, or other views), a view depends on the referenced objects. Oracle automatically handles the dependencies for views. For example, if you drop a base table of a view and then create it again, Oracle determines whether the new base table is acceptable to the existing definition of the view.

See Also: Chapter 15, "Dependencies Among Schema Objects" for a complete discussion of dependencies in a database

Updatable Join Views

A join view is defined as a view that has more than one table or view in its FROM clause (a join) and that does not use any of these clauses: DISTINCT,

AGGREGATION, GROUP BY, START WITH, CONNECT BY, ROWNUM, and set operations (UNION ALL, INTERSECT, and so on).

An updatable join view is a join view that involves two or more base tables or views, where UPDATE, INSERT, and DELETE operations are permitted. The data

10-20 Oracle9i Database Concepts

Views

dictionary views ALL_UPDATABLE_COLUMNS, DBA_UPDATABLE_COLUMNS, and

USER_UPDATABLE_COLUMNS contain information that indicates which of the view columns are updatable. In order to be inherently updatable, a view cannot contain any of the following constructs:

A set operator

A DISTINCT operator

An aggregate or analytic function

A GROUP BY, ORDER BY, CONNECT BY, or START WITH clause

A collection expression in a SELECT list

A subquery in a SELECT list

Joins (with some exceptions). See Oracle9i Database Administrator’s Guide for details.

Views that are not updatable can be modified using INSTEAD OF triggers.

See Also:

Oracle9i SQL Reference for further information about updatable views

"INSTEAD OF Triggers" on page 17-12

Object Views

In the Oracle object-relational database, an object view let you retrieve, update, insert, and delete relational data as if it was stored as an object type. You can also define views with columns that are object datatypes, such as objects, REFs, and collections (nested tables and VARRAYs).

See Also:

Chapter 13, "Object Datatypes and Object Views"

Oracle9i Application Developer’s Guide - Fundamentals

Inline Views

An inline view is not a schema object. It is a subquery with an alias (correlation name) that you can use like a view within a SQL statement.

Schema Objects 10-21

Соседние файлы в папке Oracle selected docs