Skip to content

Instantly share code, notes, and snippets.

@n0ts
Created April 5, 2010 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n0ts/356380 to your computer and use it in GitHub Desktop.
Save n0ts/356380 to your computer and use it in GitHub Desktop.
#!/bin/sh
MYSQL=/usr/bin/mysql
DATABASE="test"
SOCKET="/var/lib/mysql/mysql.sock"
# listed all tables
for table in `$MYSQL -u root $DATABASE -N -s -e 'show tables'`;
do
# show columns from table
columns=`$MYSQL -u root $DATABASE -e "show columns from $table"`
echo
echo "${table} - `echo $table | wc -l | tr -d ' '` columns"
echo "---"
echo -n "$columns"
# show indexes from table \G
indexes=`$MYSQL -u root $DATABASE -e "show indexes from $table"`
echo
echo
echo "${table} - `echo $indexes | wc -l | tr -d ' '` indexes"
echo "---"
echo -n "$indexes"
# show table status from neoad_dev like 'table' \G;
engine=`$MYSQL -u root $DATABASE -e "show table status from $DATABASE like '$table' \G" | grep "Engine: "`
echo
echo
echo "${table} - `echo $engine`"
echo
echo
echo
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment