mysql通过循环增加⾏_循环读多⾏数据插⼊到mysql中的⼀列
(脚本)mysql怎么读英语
从数据库中读出多⾏数据,⽤shell循环读出每⼀⾏,插⼊到数据库中。插成⼀条记录。
#!/bin/sh
TxIp=192.168.0.103
bindir=/usr/local/mysql/bin/mysql
datadir=/data/txdata/test
yestoday=`date -I --date='-1 days'`
#echo $Date >>
importance的英文#[ - ] && rm -
for n in $(seq 10 132)
do
IP=192.168.0.$n
$bindir -uwaptx -p"(YDtx405)" -h $TxIp -P12341 --default_character_set=GBK txbackend -e "select
python新手编程100例replace(a.description,'@value@',b.value) as ateTime from alert_config as a,alert_mobile_history_log as b where
a.id=
b.alertId and a.description like 'load%' and a.ip='$IP' and date_ateTime,'%Y-%m-%d')='$yestoday'"|sed 1d
>
exist=`cat | wc -l`
if [ $exist -eq 0 ]
then
rm -f
else
loadIp=`$bindir -uwaptx -p"(YDtx405)" -h $TxIp -P12341 --default_character_set=GBK txbackend -e "select distinct a.ip
from alert_config as a,alert_mobile_history_log as b where a.id=b.alertId and a.description like 'load%' and a.ip='$IP' and
date_ateTime,'%Y-%m-%d')='$yestoday'" | sed 1d`
alertId=`$bindir -uwaptx -p"(YDtx405)" -h $TxIp -P12341 --default_character_set=GBK txbackend -e "select distinct b.alertId from alert_config as a,alert_mobile_history_log as b where a.id=b.alertId and a.description like 'load%' and a.ip='$IP' and
excel函数参数怎么填date_ateTime,'%Y-%m-%d')='$yestoday'" | sed 1d`
loadCount=`$bindir -uwaptx -p"(YDtx405)" -h $TxIp -P12341 --default_character_set=GBK txbackend -e "select count(*) from alert_config as a, alert_mobile_history_log as b where a.id=b.alertId and a.description like 'load%' and a.ip='$IP' and
date_ateTime,'%Y-%m-%d')='$yestoday'" | sed 1d`
#n=`cat | wc -l`
#int load1[]={}
#aint time2[]={}
count=`cat wc -l`
num=1
while [ "$num" -le "$count" ]
do
while read line
do
load=`echo "$line"|awk '{print $2}'`
time=`echo "$line"|awk '{print $4}'`
if [ "$num" -eq "1" ]
then
$bindir --defaults-file=$datadir/myf txtest -e "insert into chen_load (Date,Ip,Id,count,load$num,time$num) value
('$yestoday','$loadIp','$alertId','$loadCount','$load','$time');"
else
$bindir --defaults-file=$datadir/myf txtest -e "update chen_load set load$num='$load',time$num='$time' where
Ip='$loadIp' and Date='$yestoday';"mvc框架和springboot
fi
((num++))study的汉语意思
donedone
#/usr/local/mysql/bin/mysql --defaults-file=/data/txdata/test/myf txtest -e "insert into chen_load
(Date,Ip,Id,count,load1,time1,load2,time2,load3,time3,load4,time4,load5,time5) value
('$yestoday','$loadIp','$alertId','$loadCount','$load1','$time1','$load2','$time2','$load3','$time3','$load4','$time4','$load5','$time5')"
fi
done

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。