Is there a nice easy way to drop all tables from a MySQL database, ignoring any foreign key constraints that may be in there?
相关问题
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- Why sometimes there is one of more gap(s) in the v
- mySQL alter table on update, current timestamp
Best solution for me so far
Select Database -> Right Click -> Tasks -> Generate Scripts - will open wizard for generating scripts. After choosing objects in set Scripting option click Advanced Button. Under "Script DROP and CREATE" select Script DROP.
Run script.
In php its as easy as:
Just remember to change YOURDB to the name of your database, and obviously the user/pass.
In a Linux shell like bash/zsh:
This will generate the commands, then immediately pipe them to a 2nd client instance which will delete the tables.
The clever bit is of course copied from other answers here - I just wanted a copy-and-pasteable one-liner (ish) to actually do the job the OP wanted.
Note of course you'll have to put your credentials in (twice) in these mysql commands, too, unless you have a very low security setup. (or you could alias your mysql command to include your creds.)