MySQL Query - Delete All Tables from a Database

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

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

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

Suche

Neueste Kommentare