CREATE VIEW Statement

Creates a view on the database. Views are used to give a different perspective on the data even though it is not stored that way.

Quick Links:

Go to Parameters

Go to Examples

Go to Usage

Go to Standards

Go to Permissions

Syntax

CREATE [ OR REPLACE ] VIEW
   … [ owner.]view-name [ ( column-name [ , … ] ) ]
   … AS select-without-order-by
   … [ WITH CHECK OPTION ]

Parameters

(back to top)

Examples

(back to top)

Usage

(back to top)

You cannot add or drop IDENTIFY or AUTOINCREMENT columns from a view.

Views can be updated unless the SELECT statement defining the view contains a GROUP BY clause, an aggregate function, or involves a UNION operation. An update to the view causes the underlying tables to be updated.

Side Effects
  • Automatic commit

Standards

(back to top)

  • SQL—Vendor extension to ISO/ANSI SQL grammar.
  • SAP Sybase Database product—Supported by Adaptive Server.

Permissions

(back to top)

View to be owned by self – Requires CREATE VIEW system privilege. Also requires one of:
View to be owned by any user – Requires one of:
  • CREATE ANY VIEW system privilege.
  • CREATE ANY OBJECT system privilege.
  • Also requires one of:
    • SELECT ANY TABLE system privilege.
    • SELECT object privilege on the underlying tables of the view.
Materialized view to be owned by self – Requires CREATE MATERIALIZED VIEW system privilege. Also requires one of:
Materialized view to be owned by any user – Requires one of:
  • CREATE ANY MATERIALIZED VIEW system privilege.
  • CREATE ANY OBJECT system privilege.
  • Also requires one of:
    • CREATE ANY OBJECT system privilege.
    • CREATE privilege on the dbspace where the materialized view is being created.
    And also requires one of:
    • SELECT ANY TABLE system privilege.
    • SELECT privilege on the underlying tables of the materialized view.
Related reference
CREATE TABLE Statement
DROP Statement
SELECT Statement