Creating and Using a View

A view is a predefined query on one or more tables. Querying a view is done in the same manner as retrieving from a table. Views don't store rows. Rows are always stored in tables. You can put a complex query into a view and grant users access to the view.

You create a view using CREATE VIEW:


CREATE [OR REPLACE] VIEW 
[{FORCE | NOFORCE}] VIEW view_name
[(alias_name[, alias_name ...])] AS subquery
[WITH {CHECK OPTION | READ ONLY} CONSTRAINT constraint_name];

ItemDescription
OR REPLACEthe view replaces an existing view.
FORCEcreate the view even if the base tables don't exist.
NOFORCEdon't create the view if the base tables don't exist. NOFORCE is the default.
view_namethe name of the view.
alias_namethe name of an alias for an expression in the subquery.
subqueryis the subquery that retrieves from the base tables.
WITH CHECK OPTIONmeans that only the rows that would be retrieved by the subquery can be inserted, updated, or deleted. By default, the rows are not checked.
constraint_namethe name of the WITH CHECK OPTION or WITH READ ONLY constraint.
WITH READ ONLYmeans the rows may only read from the base tables.

Privilege for Views

In order to create a view, the user must have the CREATE VIEW privilege.


GRANT CREATE VIEW TO store;
Home »
Oracle »
Table » 

Views:
  1. Creating and Using a View
  2. Creating and Using Simple Views
  3. Performing an INSERT Using a View
  4. A View with a CHECK OPTION Constraint
  5. View with a READ ONLY Constraint
  6. Getting Information on View Definitions with DESCRIBE command
  7. Getting Information on View Definitions with user_views view
  8. Retrieving Information on View Constraints
  9. Creating and Using Complex Views
  10. Modifying a View
  11. Alter the constraints on a view using ALTER VIEW
  12. Dropping a View
Related: