Created
May 14, 2014 09:55
-
-
Save pataiji/350ebfe8ad6ad98efe0e to your computer and use it in GitHub Desktop.
テーブルの一括削除のメモ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| function db_truncate_tables { | |
| database=$1 | |
| /usr/local/bin/mysql -u root -D $database -e 'show tables;' | \ | |
| cut -f 2 | grep -v Tables_in_ | \ | |
| xargs -I "@@" mysql -u root -D $database -e "set foreign_key_checks=0; DROP TABLE \`@@\`; set foreign_key_checks = 1;" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment