Last active
November 26, 2015 08:28
-
-
Save iamsebastian/edfeed776cb31a77216b to your computer and use it in GitHub Desktop.
This file contains 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
lcount=0; echo 'Please enter your mysql username:'; read mysqluser; echo '\nPlease enter your mysql password:'; read mysqlpw; echo 'SELECT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME="blz" AND !(COLUMN_KEY>"") AND TABLE_SCHEMA="macsi";' | mysql -u$mysqluser -p$mysqlpw macsi | while read -r line; do if [ "$line" != "TABLE_NAME" ]; then ((lcount++)); echo 'ALTER TABLE `'$line'` ADD INDEX(`blz`);' | mysql -u$mysqluser -p$mysqlpw macsi; fi; done; echo '\n'$(tput setaf 2)'Successfully altered '$(tput setaf 3)$lcount$(tput setaf 2)' tables (added index to them).'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment