Site icon TestingDocs.com

SQLite DROP VIEW Statement

Overview

The SQLite DROP VIEW statement removes the view from the database. Please exercise caution when using the DROP VIEW statement, as it will remove the view and its definition from the database.

SQLite DROP VIEW

The general syntax for the SQLite DROP VIEW statement is as follows:

DROP VIEW view_name;

or

DROP VIEW [IF EXISTS] view_name;

Optionally, we can use the IF EXISTS clause to avoid any error if the view doesn’t exist.

Example

Let’s say we have a view named emp_view. This is the view created on the base table emp. To remove the view from the database, we can use the following statement:

/> DROP VIEW IF EXISTS emp_view;

sqlite> .tables
emp emp_view
sqlite> DROP VIEW IF EXISTS emp_view;
sqlite>

Notice the error when the view is not present in the database.

sqlite> .tables
emp
sqlite> DROP VIEW emp_view;
Parse error: no such view: emp_view

sqlite> DROP VIEW IF EXISTS emp_view;
sqlite>

The IF EXISTS clause will suppress the error if the view is not in the database.

 

SQLite Tutorials

SQLite tutorials on this website:

https://www.testingdocs.com/sqlite-database-tutorials/

For more information on SQLite, visit the official website:

https://www.sqlite.org/

 

Exit mobile version