create view

Description

Creates a new view.

Syntax

create view [database_name.][owner.]view_name
[(column_name [, column_name]...)]
as select [distinct] select_statement
[with check option]

Parameters

view_name

is the name of the view. The view name cannot include the database name. It must conform to the rules for identifiers.

column_name

is the name of the column in the view. It must conform to the rules for identifiers.

as select

begins the select statement that defines the view.

distinct

specifies that the view cannot contain duplicate rows (optional).

select_statement

completes the select statement that defines the view. It can include more than one table and other views.

with check option

indicates that all data modification statements are validated against the view selection criteria. All rows inserted or updated through the view must remain visible through the view.

Examples

Example 1

This example creates the new view from old view.

create view new_view (col1, col2)
 as select col1, col2 from old_view

Usage

You can use views as security mechanisms by granting authorization on a view but not on its underlying tables.