MySQL Query - Delete All Tables from a Database

Submitted by Gast (nicht überprüft) on Mo, 06/01/2020 - 13:58

SQL Query:

 SELECT CONCAT('DROP TABLE ', table_schema, '.', table_name, ';') AS 'command' FROM information_schema.tables WHERE table_schema = 'MyDatabaseName' INTO OUTFILE '/tmp/sql_delete_all_tables'; 
SOURCE  /tmp/sql_delete_all_tables;

No access to "/tmp"?

 SELECT CONCAT('DROP TABLE ', table_schema, '.', table_name, ';') AS 'command' FROM information_schema.tables WHERE table_schema = 'MyDatabaseName' INTO OUTFILE './sql_delete_all_tables'; 
SOURCE  ./sql_delete_all_tables;

 

Comments

Gespeichert von Gast (nicht überprüft) am/um Mo, 06/01/2020 - 14:11

Permanenter Link

Befehl um alle Tabellen in Datenbank zu löschen:

 

SELECT CONCAT('DROP TABLE ', table_schema, '.', table_name, ';') AS 'command' FROM information_schema.tables WHERE table_schema = 'MyDatabaseName' INTO OUTFILE '/tmp/sql_delete_all_tables'; SOURCE /tmp/sql_delete_all_tables;

Man muss Schreibrechte auf /tmp besitzen. Ansonsten kann man ein anderes Pfad auswählen. 

Neuen Kommentar schreiben

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.