Summary -
In this topic, we described about the below sections -
We may need to delete the view because there is no further use in the view or when we create view wrongly. For this purpose, we can use DROP VIEW statement to delete the view. By using DROP VIEW statement, we can drop the existing view.
Syntax -
DROP VIEW view_name;
- view_name – Represents the name of the view which is going to drop.
Example -
Scenario – deleting the view.
requirement – Delete existing view employee_v.
DROP VIEW employee_v;
By executing above query, employee_v view gets dropped in database.
Scenario – Verifying the deleted view.
requirement – Verifying employee_v view gets dropped or not. The query was as follows -
SELECT * FROM employee_v;
If the view dropped successfully, we can get error message like "invalid object employee_v" by executing above query.
What happen if try to drop the non-existing view?
Let us assume employee_v view does not exist and trying to drop the view again -
DROP VIEW employee_v;
By executing above query, we can get error message like "can not drop employee because it does not exist, or you do not have permission".