Updated on 2022-11-18 GMT+08:00

DROP VIEW

Syntax

DROP VIEW [ IF EXISTS ] view_name

Description

This statement is used to delete an existing view. If the optional parameter IF EXISTS is specified and the view to be deleted does not exist, no error is reported.

Example

  • Creating a View
    create view orders_by_date as select * from orders;
  • Delete the orders_by_date view. If the view does not exist, an error is reported.
    DROP VIEW orders_by_date;
  • Delete the orders_by_date view. Use the IF EXISTS parameter. If the view exists, it will be deleted. If the view does not exist, no error will be reported.
    DROP VIEW IF EXISTS orders_by_date;