MySQL - how to drop view only if it exists?

0 points
Asked by:
Dirask Community

How can I drop a view only if it already exists in MySQL?

1 answer
3 points
Answered by:
Dirask Community

I found a solution:

We can use the following syntax so we won't get errors while trying to drop a view that doesn't exist:

DROP VIEW IF EXISTS `view_name`;

Check the article below to see some practical examples:

0 comments Add comment
Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂