Purpose
Use a SELECT statement or subquery to retrieve data from one or more tables, object tables,
views, object views, or materialized views.
If part or all of the result of a SELECT statement is equivalent to an existing materialized view,
then Oracle Database may use the materialized view in place of one or more tables specified in
the SELECT statement. This substitution is called query rewrite. It takes place only if cost
optimization is enabled and the QUERY_REWRITE_ENABLED parameter is set to TRUE. To determine
whether query write has occurred, use the EXPLAIN PLAN statement.
See Also:
Chapter 9, "SQL Queries and Subqueries" for general information on queries and
subqueries
Oracle Database Data Warehousing Guide for more information on materialized views
and query rewrite
EXPLAIN PLAN
Additional Topics
Prerequisites
Syntax
Semantics
Examples
Prerequisites
For you to select data from a table or materialized view, the table or materialized view must be in
your own schema or you must have the SELECT privilege on the table or materialized view.
For you to select rows from the base tables of a view:
You must have the SELECT privilege on the view, and
Whoever owns the schema containing the view must have the SELECT privilege on the
base tables.
The SELECT ANY TABLE system privilege also allows you to select data from any table or any
materialized view or the base table of any view.
To issue an Oracle Flashback Query using the flashback_query_clause, you must have the
SELECT privilege on the objects in the select list. In addition, either you must have FLASHBACK
object privilege on the objects in the select list, or you must have FLASHBACK ANY TABLE system
privilege.
Syntax
select::=
Description of the illustration select.gif
(subquery_factoring_clause ::=, for_update_clause ::=)
subquery::=
Description of the illustration subquery.gif
(query_block::=, order_by_clause ::=)
query_block::=
Description of the illustration query_block.gif
(select_list::=, table_reference::=, join_clause ::=, where_clause::=,
hierarchical_query_clause ::=, group_by_clause ::=, model_clause ::=)
subquery_factoring_clause ::=
Description of the illustration subquery_factoring_clause.gif
select_list::=
Description of the illustration select_list.gif
table_reference::=
Description of the illustration table_reference.gif
(query_table_expression::=, flashback_query_clause ::=, pivot_clause::=, unpivot_clause::=)
flashback_query_clause ::=
Description of the illustration flashback_query_clause.gif
query_table_expression::=
Description of the illustration query_table_expression.gif
(subquery_restriction_clause::=, table_collection_expression ::=)
pivot_clause::=
Description of the illustration pivot_clause.gif