Login

Drop all tables in MySQL database

Author:
mpasternacki
Posted:
January 28, 2010
Language:
SQL
Version:
Not specified
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 14 years, 1 month ago
  2. PostgreSQL fulltext with language translations by diverman 14 years, 2 months ago
  3. grep and delete sqlite tables by kifkif 14 years, 11 months ago
  4. Substitute hyphens with spaces to enale URLs to reference to multi-word tags by miernik 14 years, 12 months ago
  5. oneliner to delete SQLite tables by kifkif 15 years ago

Comments

Please login first before commenting.