Pejman Moghadam / Scripts

Describe all tables in a MySQL database

Public domain


#!/bin/bash
PASS="dbpass"
DB="dbname"
TABLES=$(mysql -uroot -p$PASS $DB -e 'show tables;' | tail -n +2)
for TABLE in $TABLES; do
  echo; echo $TABLE
  mysql -uroot -p$PASS $DB -e "describe $TABLE"
done

BY: Pejman Moghadam
TAG: mysql, bash, bash-script
DATE: 2011-06-11 20:53:31


Pejman Moghadam / Scripts [ TXT ]