Blogger Information
Blog 85
fans 0
comment 0
visits 72685
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
linux环境shell脚本批量从MYSQL源表插入数据到目标表
Smile
Original
740 people have browsed it

  #!/bin/bash

  i=1

  HOSTNAME="x.x.x.x"

  PORT="3306"

  USERNAME="root"

  PASSWORD="111111"

  maxid=17301353

  minid=17301353

  while :

  do

  #echo "$i"

  sleep 0.5

  (( i++ ))

  maxid=`expr $minid`

  minid=`expr $minid - 10000`

  echo $minid,$maxid

  mysql -u $USERNAME -p$PASSWORD -h $HOSTNAME -P $PORT << EOF

  use db0825;

  insert into tab1111_bak

  select * from tab1111 where id>$minid and id<=$maxid;

  EOF

  if ((i==20))

  then

  break

  fi

  done

  说明:

  1)需从源表找到最大的ID,并赋maxid和minid参数为初始值;

  2)minid在每次循环时减10000,即每次循环10000条数据;

  3)循环次数i ,根据实际情况指定,本例子是20次循环退出,即本例子卖手游账号总共插入目标表19万条数据。

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post