Skip to content

Instantly share code, notes, and snippets.

@cmerrick
Created October 20, 2015 02:50
Show Gist options
  • Save cmerrick/63dfb45ddf9708e0010b to your computer and use it in GitHub Desktop.
Save cmerrick/63dfb45ddf9708e0010b to your computer and use it in GitHub Desktop.

Revisions

  1. Christopher Merrick created this gist Oct 20, 2015.
    7 changes: 7 additions & 0 deletions truncate-db
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    #!/bin/bash

    DB=$1

    mysql -Ne "SELECT TABLE_NAME FROM TABLES WHERE TABLE_SCHEMA='$1'" INFORMATION_SCHEMA | while read TABLE; do
    mysql -Ne "TRUNCATE \`$TABLE\`" $DB
    done