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
| Parameter | Type | Description |
|---|---|---|
view_name | string | A distinct identifier used to name the view. |
query | string | A SELECT query that defines the data from a table used to create the view. |
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
| Parameter | Type | Description |
|---|---|---|
view_name | string | The identifier of the view to drop. You can drop multiple views by specifying additional view names and separating each with commas. |
star_employees.
SQL
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:
VIEWprivilege on the current schema of the viewVIEW VIEWandCREATE VIEWprivileges on the target schema (if the schema already exists)CREATE VIEWprivilege on the database (if the schema does not exist)
SQL
| Parameter | Type | Description |
|---|---|---|
old_view_name | string | The identifier of the view to rename. |
new_view_name | string | The new name for the specified view. |
star_employees to star_mid_west_employees.
SQL
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
| Parameter | Type | Description |
|---|---|---|
view_name | string | The identifier for the view to alter. |
query | string | A SELECT query that defines the new data from a table used to alter the view. |
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
| Parameter | Type | Description |
|---|---|---|
view_name | string | The identifier for the view to export. |
students.
SQL

