ITPub博客

首页 > 数据库 > MySQL > MYSQL创建多张表,相同表结构,不同表名

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

原创 MySQL 作者:haoge0205 时间:2013-11-28 13:29:20 0 删除 编辑

#!/bin/bash
for i in {0..63}
do

mysql -u$1 -p$2 -h127.0.0.1 < 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

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28939273/viewspace-1061492/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-11-28

  • 博文量
    300
  • 访问量
    1893479