用shell指令碼來給mysql加索引

stpeace發表於2018-01-15

      剛好用到, 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_"都可以


相關文章