Shell script to crop all MySql tables

I am looking for a Unix shell script that trims all tables in a schema. A similar question has already been asked, but I have some additional requirements that do not give a satisfactory answer to any of the answers presented:

  • There must be a Unix script shell (i.e. no python, perl, PHP)
  • the script should trim the tables in the order that matches the foreign key constraints
  • I would prefer not to use the proc stored procedure

Thanks in advance, Don

+3
source share
1 answer

How about something cheeky:

mysqldump  --no-data mydb | mysql mydb

Gets a dump of the circuit and repeats it in the database!

, mk-find Maatkit, - :

mk-find -exec "truncate %s"

mk-find:

MySQL UNIX. (, " 1 " ) , SQL ( "DROP TABLE% s" ). , , - . , cron.

+6

All Articles