Methods for all tables in MySQL

Source: Internet
Author: User

MySQL method to delete all tables in the database:


--  switch to the database where you want to delete the table use replace_with_database_name_you_want_to_delete;--  Delete all tables Set foreign_key_ checks = 0; set group_concat_max_len=32768; set  @tables  = NULL; Select group_concat (", table_name, ")  INTO  @tables   FROM  information_schema.tables  where table_schema =  (Select database ()); Select ifnull (@tables, ' dummy ')  INTO  @tables; set  @tables  = concat (' drop table if exists  ',  @tables); prepare stmt from  @tables; execute stmt;deallocate prepare stmt; set foreign_key_checks = 1;--  Delete all views set foreign_key_checks = 0; set group_concat_max_len=32768; set  @views  = NULL; Select group_concat (", table_name, ")  INTO  @views   FROM  information_schema.views  where table_schema =  (Select datAbase ()); Select ifnull (@views, ' dummy ')  INTO  @views; set  @views  = concat (' drop view if exists  ',  @views); prepare stmt from  @views; execute stmt;deallocate prepare stmt; set foreign_key_checks = 1;




This article is from the "GONE with the Wind" blog, please be sure to keep this source http://h2appy.blog.51cto.com/609721/1676871

Methods for all tables in MySQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.