CREATE VIEW Statement

Creates a view of data from one or more tables or other views.

Category: Data Definition
Data source: SAS data set, SPD Server table, Aster, DB2 under UNIX and PC, Greenplum, HAWQ, HDMD, Hive, Impala, MDS, MySQL, Netezza, ODBC, Oracle, PostgreSQL, SAP HANA, Teradata

Syntax

Arguments

SECURITY security-type

specifies the type of security that will be enforced for the view. security-type can be one of the following values.

DEFINER

specifies that the view is run with the schema owner’s credentials.

INVOKER

specifies that the view is run with the invoking user’s credentials.

Default If SECURITY is not used, security for the view defaults to INVOKER.
Restriction Security is available only with SAS Federation Server. The SECURITY security-type argument is ignored in a FedSQL request that is not directed to SAS Federation Server. For more information about the security available through SAS Federation Server, see the documentation for SAS Federation Server.

view

specifies the name of the view being created.

Requirement The view name must be different from any other view, table, or index in the same database.

query-expression

specifies the SELECT statement that retrieves the information from an existing table that is used to create the view.

See Creating and Populating Tables from a Query Expression, Query Expressions and Subqueries, and SELECT Statement

Details

Overview of the CREATE VIEW Statement

A view is a definition of a virtual table that is formed by a query expression against one or more tables or other views. A view contains no data. The view definition is stored as metadata and consists of the view name, possibly the name of the columns in the view, and the query expression that is used to derive its rows.
If an underlying table or view in a view is deleted, SAS returns an error message when the view is executed. If the underlying table or view is changed, the view might have to be re-created.

Access to Views

To create a view, you must have CREATE VIEW privilege. As the view owner, you have all privileges for the view, including the ability to grant privileges to other users. To execute a view, the user must have SELECT privilege on the tables and views that are referenced in the view.

SELECT Statement Restrictions

The SELECT statement cannot include an ORDER BY clause.
Last updated: February 23, 2017