MySQL DROP all tables, ignoring foreign keys

前端 未结 24 2782
醉梦人生
醉梦人生 2020-12-02 03:44

Is there a nice easy way to drop all tables from a MySQL database, ignoring any foreign key constraints that may be in there?

24条回答
  •  感动是毒
    2020-12-02 03:53

    You can do:

    select concat('drop table if exists ', table_name, ' cascade;')
      from information_schema.tables;
    

    Then run the generated queries. They will drop every single table on the current database.

    Here is some help on drop table command.

提交回复
热议问题