使用shell脚本来给mysql加索引的方法
时间:2020-12-07 16:29:35|栏目:Shell|点击: 次
用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_"
都可以
总结