updated mysql_foreach_table.sh

pull/2/head
Hari Sekhon 4 years ago
parent 42e99487a6
commit 86c3340554

@ -13,27 +13,36 @@
# https://www.linkedin.com/in/harisekhon
#
# Run SQL query against all MySQL tables in all databases via mysql.sh
#
# Query can contain {db} and {table} placeholders which will be replaced for each table
#
# FILTER environment variable will restrict to matching fully qualified tables (<db>.<table>)
#
# Auto-skips information_schema, performance_schema, sys and mysql databases for safety
#
# Tested on MySQL 8.0.15
set -eu # -o pipefail
set -eu # o pipefail
[ -n "${DEBUG:-}" ] && set -x
srcdir="$(dirname "$0")"
srcdir="$(dirname "${BASH_SOURCE[0]}")"
# shellcheck disable=SC1090
. "$srcdir/lib/utils.sh"
# shellcheck disable=SC2034,SC2154
usage_description="
Run SQL query against all MySQL tables in all databases via mysql.sh
Query can contain {db} and {table} placeholders which will be replaced for each table
FILTER environment variable will restrict to matching fully qualified tables (<db>.<table>)
Auto-skips information_schema, performance_schema, sys and mysql databases for safety
Tested on MySQL 8.0.15
"
# used by usage() in lib/utils.sh
# shellcheck disable=SC2034
usage_args="\"<query>\" [<mysql_options>]"
help_usage "$@"
if [ $# -lt 1 ]; then
echo "usage: ${0##*/} <query> [mysql_options]"
exit 3
fi
min_args 1 "$@"
query_template="$1"
shift
shift || :
# exit the loop subshell if you Control-C
trap 'exit 130' INT

Loading…
Cancel
Save