用shell脚本来给mysql加索引

前端之家收集整理的这篇文章主要介绍了用shell脚本来给mysql加索引前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

刚好用到, mark一下:

#! /bin/bash

tb_base=tb_student_
arr=("0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f")

GetCmd()
{
	for value in ${arr[@]}
	do
		for value2 in ${arr[@]}
		do
			tb_name=$tb_base$value$value2

			cmd="ALTER TABLE ${tb_name} ADD INDEX seed (uid,name);  "
			
			echo $cmd
		done
	done
}

GetCmd $1
上面的结果就是要执行的语句, done.

嗯,tb_student_和"tb_student_"都可以

原文链接:https://www.f2er.com/bash/388996.html

猜你在找的Bash相关文章