我想将DDL从一个数据库复制到另一个数据库,原因是,我想让dev 1:1像prelive一样,为视图复制DDL。
当我想要复制视图的名称时,他将所有名称都放入dev:2000视图中,但是当我想复制DLL时,我只获得180个DDL视图。
是因为我的变量因为空间不足而无法捕获所有DDL吗?
#!/usr/bin/perl
use strict;
use warnings;
use Sybase::DBlib;
use Sys::Hostname;
use Getopt::Std;
## additionals
use lib "/opt/db/perllib";
use ADDITIONALS;
my ($dsn, $database, $dbserver, $dbname, $user, $passwd, $rmdb_config ) = ('','','','','','',''); #PRELIVE CONNECTION
my ($database2, $dbserver2, $dbname2, $user2, $passwd2) = ('','','','',''); #DEV CONNECTION
my %db_data;
my @arr_tab;
my $copy_view;
my $dbhandle_prelive; #PREL
my $dbhandle_dev;
my $dbdrop;
my $user = "rmdb_dbo";
$dbserver = "DB01";
$dbname = "DB01";
$config = "$ENV{ENV_DIR}";
$dsn = "dbi:Sybase";
$database = join (' ~ ',$dsn, $dbserver, $dbname, $user, $passwd, $config);
$dbhandle_prelive = connect_me($database); #PRELIVE CONNECTION
$database2 = join (' ~ ',$dsn, $dbserver2, $dbname2, $user2, $passwd2, $config);
$dbhandle_dev = connect_me($database2); #DEV CONNECTION
my $get_ddl = '';
my $i = 0;
$get_ddl= "select column = column from ddl_view;";
$dbhandle_prelive->dbcmd($get_ddl);
$dbhandle_prelive->dbsqlexec;
while($dbhandle_prelive->dbresults != NO_MORE_RESULTS) {
while(%db_data = $dbhandle_prelive->dbnextrow(1)) {
push (@arr_tab, $db_data{column});
my $copy_view = ("insert into ddl_view values ('".$arr_tab[$i]."')");
print $copy_view, "\n";
$dbhandle_dev->dbcmd($copy_view);
$dbhandle_dev->dbsqlexec;
$i++;
print $i;
}
}