In this article we will show how to drop a view in
SQLite database using the
DROP VIEW statement.
The DROP VIEW statement followed by a view name drops the view from the SQLite database.
When a view is deleted, the optional
IF EXISTS clause can be used so as to avoid a possible error that would result if the view we want to delete does not exist. The syntax for deleting a view from the SQLite database is as follows:
DROP VIEW [IF EXISTS] [schema_name].view_name;
The following example shows the creation of a view in the SQLite database, to then remove the view.
In the DROP VIEW statement we will also use the optional IF EXISTS clause that we discussed above at the beginning of the article.
CREATE VIEW report_orders_view AS SELECT order_id, customer_id, amount FROM orders WHERE amount > 100;
To remove the report_orders_view view from SQLite database, execute the following statement:
DROP VIEW IF EXISTS report_orders_view;