導入數據后發現大量分區字段插入錯誤,需要批量刪除分區,發現不能批量操作,只能手寫一個腳本分布執行。
shell 腳本如下:
ports="8888" user='' pwd='' host='' dbtable='' drop_sql=(`curl -u $user:$pwd 'http://host:ports/?' -d "select concat('alter table $dbtable drop partition',partition) as drop_sql from system.parts where `table` ='$dbtable'"`) for i in "${drop_sql[@]}" do curl -u $user:$pwd 'http://'$host':'$port'/?' -d "$i;" echo '============ successful===============' done