Operations with views

Create a new view

CREATE [OR REPLACE] VIEW [IF NOT EXISTS] [<view_schema>.]<view_name> AS
    <select_expr>

Creates a new view with the specified name based on the result of the specified SELECT query.

Parameters

  • <view_name> — name of the view to be created


  • <view_schema> — schema of the view to be created


  • <select_expr> — SELECT expression, based on the result of execution of which the view will be created

If the OR REPLACE modifier is specified, the final action is equivalent to deleting the existing view and creating a new one with the same name.

The optional IF NOT EXISTS modifier restricts the query to only those cases in which the specified object does not already exist.

The modifiers are mutually exclusive. Specifying them both will result in an error.

Deleting a view

DROP VIEW [IF EXISTS] <view_name>;

Removes the view from the system.

The optional IF EXISTS modifier restricts the query to only those cases in which the specified object exists.