Clear all tables in a MySQL database

Source: Internet
Author: User
Method 1: Use mysqldump -- no-data to export the SQL statement for creating the database and table, drop the database, create the database, execute the exported SQL file, and create the table. Method 2: generate sqlmysql-n-s information_schema-e "select Concat ('truncate table', table_name, ';') from tables where table_schema = 'eab12 '"
The output result is as follows: truncate table authgroupbindings;
Truncate table authgroups;
Truncate table authusers;
Truncate table corpbadcustominfo;
Truncate table corpsmsblacklisyinfo;
Truncate table corpsmsfilterinfo;
Truncate table corpsmsinfo;
Truncate table eabasereginfos;
Truncate table eacorpblob;
Truncate table eacorpinfo ;........ this improves: mysql-n-s information_schema-e "select Concat ('truncate table', table_name ,';') from tables where table_schema = 'ab12' "| MySQL eab12 clears all tables in eab12. However, if a foreign key exists, an error may be reported. Therefore, you also need to add-fmysql-n-s information_schema-e "select Concat ('truncate table', table_name ,';') from tables where table_schema = 'ab12' "| mysql-F eab12 is executed several times until no error is reported.
Related Article

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.