I developed a project in JavaFX. Its back-end is MySQL. For my project I created a database named 'project' in MySQL. Now this database contains 8 tables. I want to make the database empty when a button is pressed, that is delete all tables, not database. Should I have to empty each table and delete them or is there any other easy way to clear the database ?
Asked
Active
Viewed 185 times
2 Answers
1
Easiest way:
DROP DATABASE project; CREATE DATABASE project;
longer way:
SHOW TABLES FROM project;
and iterate through the tables with
DROP TABLE project.<tablename>;

flaschenpost
- 2,205
- 1
- 14
- 29
-
-
Yeah, be careful with those commands. Normally the "working user" should not be allowed those commands, it should be task of a structure admin. – flaschenpost Apr 21 '14 at 15:48
-
-
1You can define different users for the database (username/password for the MySQL-Connection), one can insert, delete, update and is used in the Web-App, the other user can also drop tables, drop databases, alter tables and so on. I just mean: be careful in which situations you fire a "DROP DATABASE" Command. – flaschenpost Apr 21 '14 at 16:07