Delete data from all tables in MYSQL

前端 未结 16 1763
自闭症患者
自闭症患者 2020-12-13 09:17

I have 100 tables, 40,000 rows in each table. I want to go into MySQL and delete all rows from all tables.

...in 1 statement, if p

16条回答
  •  我在风中等你
    2020-12-13 10:03

    $ mysqldump --no-data -u [username] -p[password] [database] > [location]
    $ mysql -u [username] -p[password]
    mysql > drop database [database]; create database [database];
    mysql > exit;
    $ mysql -u [username] -p[password] [database] < [location]
    

    The --no-data switch preserves only the database table information, and will ignore all table data; you merely have to reimport the generated .sql file to regain all table information.

提交回复
热议问题