MySQL - how to drop table only if exists?

0 points
Asked by:

How can I drop the table in MySQL only if it exists?

1 answer
0 points
Answered by:

I found a solution:

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

DROP TABLE IF EXISTS `table_name`;

Check the article below to see some practical examples:

0 comments Add comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
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.

❤️💻 🙂