Skip to main content
This group of DDL SQL statements allows database administrators to manage views. Database administrators can create, modify, drop, and export views. You can view information about views using the sys.views system catalog table. For information on database components, see the pages on Databases, Schemas, Tables, and Indexes.

CREATE VIEW

CREATE VIEW creates a new view in the current database or replaces an existing view. For view creation, the name of the view must be distinct from the name of any existing views in the database. To create a view, you must have both the CREATE VIEW privilege for the current database and the SELECT privilege on all directly referenced tables and views in the query. You must have DROP privileges on the view. You also must have CREATE VIEW privileges on the database. Syntax
SQL
Example This example creates an existing view in the current database and schema named option_trades.
SQL

DROP VIEW

DROP VIEW removes one or more existing views in the current database. To remove a view, you must have the DROP VIEW privilege for the view. Syntax
SQL
Example This example drops an existing view in the current database and schema named star_employees.
SQL
This example drops two views named star_employees and bad_employees.
SQL

ALTER VIEW RENAME

ALTER VIEW RENAME renames an existing view. Required Privileges To rename a view, you must have the ALTER VIEW privilege for the view. The System requires these privileges if this statement includes a change to the schema:
  • VIEW privilege on the current schema of the view
  • VIEW VIEW and CREATE VIEW privileges on the target schema (if the schema already exists)
  • CREATE VIEW privilege on the database (if the schema does not exist)
Syntax
SQL
Examples This example renames an existing view in the current database and schema named star_employees to star_mid_west_employees.
SQL
This example renames an existing view in the current database named us.star_employees to us.star_mid_west_employees.
SQL

ALTER VIEW AS

ALTER VIEW AS modifies an inner query of the existing view. To modify the query for an existing view, you must be a system-level user or have the ALTER VIEW privilege for the view. You must also have the SELECT privilege on all referenced tables and views in the new query. Syntax
SQL
Example This example alters a view in the current database and schema named star_employees.
SQL

EXPORT VIEW

EXPORT VIEW shows the CREATE VIEW statement for an existing view in the current database. To export a view, the logged-in user must be a system-level user or have the READ VIEW right for the view. Syntax
SQL
Example This example exports an existing view in the current database and schema named students.
SQL
Core Elements of an Ocient System Data Query Language (DQL) Statement Reference Database Password Security Settings System Catalog
Last modified on June 24, 2026