欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

sqlserver数据导入mysql四:给sqlserver中的表创建索引

程序员文章站 2022-05-04 22:41:43
...

欢迎进入Windows社区论坛,与300万技术人员互动交流 >>进入 my $cols=$dbh2 - prepare($sql); $cols-execute(); my $cols_str = ""; my $n=0; $sort_column=""; while(@col= $cols-fetchrow_array()) { ($col_name,$type_name,$max_length,$preci

欢迎进入Windows社区论坛,与300万技术人员互动交流 >>进入

  my $cols=$dbh2 -> prepare($sql);

  $cols->execute();

  my $cols_str = "";

  my $n=0;

  $sort_column="";

  while(@col= $cols->fetchrow_array())

  {

  ($col_name,$type_name,$max_length,$precision,$scale,$is_nullable,$is_identity)=@col;

  if($is_identity == 1)

  {

  $ok=1;

  $sort_column="$col_name";

  }

  }

  }

  sub do_sql

  {

  print '开始创建'.$_[0].'表的索引'.$_[1]."\n";

  my $sql_create="CREATE UNIQUE INDEX $_[1] ON $_[0] ($_[1])";

  my $dbh_mssql=DBI->connect("dbi:ODBC:$source_name",$source_user_name,$source_user_psd,{RaiseError =>1});

  $dbh_mssql->{LongTruncOk}=1;

  $dbh_mssql->{LongReadLen}=1048576;

  my $sth_select=$dbh_mssql->prepare($sql_create);

  # open(FILE,"》all_export_data222.txt");

  # syswrite(FILE,"$sql_select\n");

  # close(FILE);

  $sth_select->execute() or die 'Cannot execute: '. $sth_select->errstr();

  print '创建'.$_[0].'表的索引'.$_[1].'结束'."\n";

  }

[1] [2]

sqlserver数据导入mysql四:给sqlserver中的表创建索引