Login

Drop all tables in MySQL database

Author:
mpasternacki
Posted:
January 28, 2010
Language:
SQL
Version:
Not specified
Tags:
sql mysql maintenance
Score:
1 (after 1 ratings)

Drops all tables in MySQL table (either managed by Django or not). Useful when resetting the database with no CREATE DATABASE privileges. MySQL-only.

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

Comments

Please login first before commenting.