标题:
sqlserver数据导入mysql三: 把生成的表分成几份
[打印本页]
作者:
look_w
时间:
2019-4-19 19:49
标题:
sqlserver数据导入mysql三: 把生成的表分成几份
#!/usr/bin/perl
use Encode;
use Encode::CN;
use DBI;
use Switch;
use strict;
use Net::HandlerSocket;
use threads;
use Time::HiRes 'time';
print "请输入数字确认要把所有表分成几份";
my $var=0;
$var=<STDIN>;
chop ($var);
print "请输入总表名";
my $read=0;
$read=<STDIN>;
chop ($read);
my $readtxtname=$read;
my @a;
open(FILE,"$readtxtname");
while (<FILE>) {
chomp;
if(defined($_ ))
{
push @a,$_;
}
}
close(FILE);
my $many=int(@a/$var);
my $count=@a;
print $many."\n";
print $count."\n";
my $i=1;
while($i<=$var){
my $outtxtname="alltablename_exportname_"."$i"."\.txt";
my $index=$many*($i-1);
if($i==$var)
{
while($index<=@a-1){
open(FILE,">>$outtxtname");
syswrite(FILE,"@a[$index]\n");
syswrite(FILE,"@a[$index+1]\n");
close(FILE);
$index=$index+2;
}
}
else
{
while($index<=$many*$i-1){
open(FILE,">>$outtxtname");
syswrite(FILE,"@a[$index]\n");
syswrite(FILE,"@a[$index+1]\n");
close(FILE);
$index=$index+2;
}
}
$i++;
}
print "ok";
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/)
Powered by Discuz! 7.0.0