mysqldump views bash script
Добрый
sakvoiazh
#! /bin/bash
db_list=`mysql -e "show databases" `
for db in $db_list ; do
>$db.sql
view_list=`mysql -e "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_TYPE LIKE 'VIEW' AND TABLE_SCHEMA LIKE '${db}';" | grep -v TABLE_NAME`
 for view in $view_list;do
 
    echo "$db $view"
echo "drop view IF EXISTS $view ;" >>$db.sql
echo "drop table IF EXISTS $view ;" >>$db.sql
 mysql $db -e "show create view $view\G" |grep "Create View: " | sed -e 's/Create View: / /1' | sed s/.*/'&;'/ >>$db.sql
 done
done

?

Log in

No account? Create an account