CREATE/REPLACE VIEW SQL Statement | VantageCloud Lake - CREATE VIEW and REPLACE VIEW - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Creates or replaces a view on a set of tables or views or both.

REPLACE VIEW redefines an existing view or, if the specified view does not exist, creates a new view with the specified name. Privileges that were granted directly on the original view are retained for the replace view definition.

CREATE/REPLACE VIEW and CREATE/REPLACE RECURSIVE VIEW (see CREATE RECURSIVE VIEW and REPLACE RECURSIVE VIEW) share most of the same code and are variations of each other, but are documented separately for clarity.

ANSI Compliance

CREATE VIEW is ANSI SQL:2011-compliant.

REPLACE VIEW is a Teradata extension to the ANSI SQL:2011 standard.

Required Privileges: CREATE VIEW

To create a view, you must have the CREATE VIEW privilege.

The creator has the DROP VIEW, INSERT, UPDATE, DELETE, and SELECT privileges on the newly created view WITH GRANT OPTION.

If a user other than the owner accesses a view, then all of the relevant privileges needed by the immediate owner of the view to access underlying tables and views must also be held by the immediate owner of the view WITH GRANT OPTION.

You must have the following privileges to update a table through a view.

User Privileges Required
Immediate owner of view
  • UPDATE on the view.
  • UPDATE on the table.
Other users
  • UPDATE on the view.
  • UPDATE WITH GRANT OPTION on the table.

You must have the following privileges to delete rows from a table through a view:

User Privileges Required
Immediate owner of view
  • DELETE on the view.
  • DELETE on the table.
Other users
  • DELETE on the view.
  • DELETE WITH GRANT OPTION on the table.

You must have the following privileges to update or delete rows from a table using a search condition through a view:

User Privileges Required
Immediate owner of view
  • SELECT ACCESS on the view.
  • SELECT ACCESS on the table.
Other users
  • SELECT ACCESS on the view.
  • SELECT ACCESS WITH GRANT OPTION on the objects specified in the search condition list.

Required Privileges: REPLACE VIEW

You must have the relevant privileges listed in the preceding sections and the following additional privileges to replace a view:
  • DROP VIEW privilege.
  • CREATE VIEW privilege if the specified view does not exist.

Privileges Granted Automatically

When you create a new view, the following privileges are automatically granted to the view:
  • DELETE
  • DROP VIEW
  • GRANT
  • INSERT
  • SELECT
  • UPDATE