I need to drop all the tables in a database without knowing their names beforehand. The typical procedure is to drop and then recreate the database but this is not an option. What is the best way to do it?
|
|
There is a simpler bash one-liner using mysqldump (from Thingy Ma Jig Blog).
If you're getting this error:
Try the following:
Now it ignores the constraints. |
||||
|
|
|
You should use the information_schema tables to fetch the metadata about the database, and then drop the tables listed there. |
|||
|
|
|
You could try a quick shell script to do it too:
Remove |
|||||||
|
|
There was an entry on the Xaprb blog recently which covers this nicely. It includes why using Try the following with
If you're happy with the results then:
|
|||
|
|
|
If you have filesystem access, then just The Drop database statement does the same... Excerpt from the MySQL manual: The DROP DATABASE statement removes from the given database directory those files and directories that MySQL itself may create during normal operation: |
|||||||
|