Home  >  Article  >  Database  >  How to delete all tables in mysql database

How to delete all tables in mysql database

王林
王林Original
2020-10-14 16:15:338168browse

Mysql method to delete all tables in the database: directly execute the [SELECT table_name FROM information_schema.tables WHERE table_schema = 'mydb';] statement to delete.

How to delete all tables in mysql database

Just execute the following SQL statement directly on the command line:

(Recommended tutorial: mysql video tutorial)

SELECT concat('DROP TABLE IF EXISTS ', table_name, ';')
FROM information_schema.tables
WHERE table_schema = 'mydb';

Explanation: mydb represents the database name of the table to be deleted.

Related recommendations: mysql tutorial

The above is the detailed content of How to delete all tables in mysql database. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn