您的位置:首页 > 数据库 > Oracle

oracle数据库导出导入--perl脚本实现

2009-07-08 15:13 417 查看
 

#导出oracle数据库

#!/usr/bin/perl -w

`set NLS_LANG=AMERICAN_AMERICA.AL32UTF8`;

my @aa=`exp system/******/@dbname file=d:/daochu.dmp owner=(cm)`;

foreach(@aa){

  print $_;

}

print "==============oracle data exp end=====================";

 

 

###########################################################

#导入oracle数据库

 

#!/usr/bin/perl -w

 

use DBI;

$dbname="YUYU";

$user="username";

$passwd="passwd";

$dbh="";

print "start...... /n";

$dbh = DBI->connect("DBI:Oracle:$dbname",$user,$passwd) or die "can't connect to database ". DBI-errstr;

 

##delete user

$sth=$dbh->prepare("drop user username cascade");

$sth->execute;

print "drop user cm /n";

##create user

$sth=$dbh->prepare("create user username IDENTIFIED BY passwd");

$sth->execute;

print "create user username/n";

##grant  role

$sth=$dbh->prepare("grant dba to username");

$sth->execute;

print "grant dba to username/n";

##close dbbase;

$dbh->disconnect;

 

print "==============oracle data imp start=====================";

##imp oracle date##

my @aa=`imp username/passwd/@YUYU  file=e:/daochu.dmp fromuser=username`;

foreach(@aa){

  print $_;

}

 

print "==============oracle data imp end=====================";

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息