Last active
December 28, 2015 03:29
-
-
Save jaronson/7435965 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
#!/bin/bash | |
export MYSQL_PASS= | |
function mysql_search_schema_usage(){ | |
cat << EOF | |
usage: $0 <terms> [database] | |
EOF | |
} | |
function mysql_search_schema(){ | |
if [[ -z $1 ]] | |
then | |
mysql_search_schema_usage | |
else | |
cmd="mysql -uroot -p$MYSQL_PASS -e" | |
query="SELECT table_schema, table_name, column_name FROM information_schema.columns WHERE (table_name LIKE '%$1' OR column_name LIKE '%$1')" | |
if [[ -n $2 ]] | |
then | |
query="$query AND table_schema = $2" | |
fi | |
eval "$cmd \"$query\"" | |
fi | |
} | |
alias searchschema=mysql_search_schema |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment