DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Procedure Analyse Against All Tables

10.22.2011
| 2323 views |
  • submit to reddit
        // Finding optimum column type based on the data already entered, using procedure analyse for each table.
// # usage analyse.sh myDB_Name


#!/bin/bash
# finding optimum column type based on the data already entered
# using procedure analyse for each table
# usage analyse.sh myDB_Name

> /backup/max.txt
while read tblname ; do
mysql -e"select * from $tblname procedure analyse()\G" >> /backup/max.txt
done <<HERE
 `mysql -Be"select CONCAT(TABLE_SCHEMA, '.' , TABLE_NAME) as noname from INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '$1'"`
HERE