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

  1. create_template_postgis-ubuntu_lucid by clawlor 10 years, 1 month ago
  2. PostgreSQL fulltext with language translations by diverman 10 years, 2 months ago
  3. Drop all tables in MySQL database by mpasternacki 10 years, 8 months ago
  4. grep and delete sqlite tables by kifkif 10 years, 10 months ago
  5. Substitute hyphens with spaces to enale URLs to reference to multi-word tags by miernik 10 years, 11 months ago

Comments

Please login first before commenting.