shell实现sql多字段递增(升级版)

需求:在指定范围内实现ID和序列号、名称等字段自增

脚本如下:

#! /bin/bash
# i为递增ID,step为执行次数,no为递增序列号
i=120943000000220593
step=0
no=990
while (($step<=1032))
do
  ((step++))
  let no+=1
  # echo $step
  id=$(($i+$step))
  # echo $id
  echo "INSERT INTO SG_DATACENTER.SG_DEV_TOWER_B (REGION,SUPPLIER_ID,TYPE,ID,LONGITUDE,STAMP,TOWERNO,ALTITUDE,CHECK_CODE,MODEL,LATITUDE,OWNER,DEV_ID,OFF_TIME,ON_TIME,TOWERNAME,INITIAL_LINE,TOWERHEIGHT) VALUES(null,null,null,'$id',111.601300,'430000_00614300000295_2021-05-27 12:18:20',$no,null,null,'名称#$no',29.090000,'430000',null,null,null,'名称#$no',null,null);" >> insert_tower.sql
  echo "INSERT INTO SG_DATACENTER.SG_DEV_DCLINE_R_TOWER (LINE_ID,TOWER_ID,OWNER,STAMP,TOWERNAME,TOWERNO,LATITUDE,LONGITUDE) VALUES ('120699010000000024','$id','430000','430000_00614300000295_2021-05-27 12:18:20','名称#$no',$no,20,20)" >> insert_R.sql
done

你可能感兴趣的:(shell实现sql多字段递增(升级版))