Drop all tables in MySQL database

1
2
3
4
5
echo 'show tables;' \
    | python manage.py dbshell \
    | sed -n 2,\$p \
    | awk 'BEGIN {print "set foreign_key_checks=0;"} { print "drop table `" $1 "`;"}' \
    | python manage.py dbshell

More like this

  1. Custom SQL via subquery by drg006 4 years, 9 months ago
  2. Locking tables by miohtama 3 years, 7 months ago
  3. Creating MySQL Alter table commands for Foreign Keys by vidyanand 3 years, 7 months ago
  4. Clean up expired django.contrib.session's in a huge MySQL InnoDB table by patsplat 3 years, 1 month ago
  5. Bulk Insert - updated 5/9/2008 by coolie 4 years, 3 months ago

Comments

(Forgotten your password?)