MYSQL创建多张表,相同表结构,不同表名

#!/bin/bash
for i in {0..63}
do
mysql -u$1 -p$2 -h127.0.0.1 <<EOF
use yoon;
create table ivc_pre_detail_$i
(
id bigint not null,
refId bigint,
detailType smallint,
wid int comment '商品编号',
wname varchar(150) comment '商品名称',
num int comment '商品数量',
price decimal(16,6) comment '商品价格',
unit varchar(10) comment '商品单位',
spec varchar(50) comment '规格型号',
taxRate decimal(16,6),
uuid varchar(50) comment '防重唯一标识',
createTime datetime comment '创建时间',
hashTime datetime comment '分库时间',
primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
alter table ivc_pre_detail_$i comment '普票临时预开明细';
EOF
done

原文地址:https://www.cnblogs.com/hankyoon/p/5169565.html