Summary: in this tutorial, you will learn how to use the Db2
DROP VIEW statement to remove a view from the database.
DROP VIEW statement
To remove a view from the database, you use the
DROP VIEW statement:
DROP VIEW view_name;
In this syntax, you just need to specify the name of the view that you want to delete in the
DROP VIEW clause.
Once you delete the view, Db2 will mark all views that depend on the deleted view inoperative.
Db2 doesn’t allow you to delete multiple views using a single
DROP VIEW statement. Therefore, you have to execute multiple
DROP VIEW statements to delete multiple views.
In other database systems, you may find that they have
DROP VIEW IF EXISTSstatement to conditionally delete a view only if it exists. However, Db2 doesn’t support
IF EXISTS clause.
DROP VIEW example
We’ll use the
book_details view created in the
CREATE VIEW tutorial for the demonstration.
The following statement uses the
DROP VIEW statement to remove the view
DROP VIEW book_details;
In this tutorial, you’ve learned how to use the
DROP VIEW statement to delete a view from the database.