Chinaunix首页 | 论坛 | 博客
  • 博客访问: 226502
  • 博文数量: 50
  • 博客积分: 1415
  • 博客等级: 上尉
  • 技术积分: 541
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-03 11:48
文章分类

全部博文(50)

文章存档

2010年(38)

2009年(12)

我的朋友

分类:

2010-04-25 14:58:06

#!/usr/local/bin/perl -w

use DBI;
use strict;
delete $ENV{ 'ENV' };
$ENV{ORACLE_SID} = "ORCL";
$ENV{ORACLE_HOME} = "/opt/oracle/product/10.2.0";
$ENV{NLS_LANG} = "AMERICAN_AMERICA.AL32UTF8";
$ENV{ORA_NLS} = $ENV{ORACLE_HOME} . "/ocommon/nls/admin/data";
$ENV{PATH} = $ENV{ORACLE_HOME} . "/bin:/usr/bin";
$ENV{LD_LIBRARY_PATH} = $ENV{ORACLE_HOME} . "/lib";
my $connect_mode = 2; # 2=SYSDBA

my $dbh = DBI->connect( 'dbi:Oracle:','', '',
        { ora_session_mode => $connect_mode,
          PrintError => 1, AutoCommit => 0 } )
        or die "Cannot connect: $DBI::errstr\n\n";
print "Connected.\n";

 

 


 

#!/usr/bin/perl


use DBI;
use DBI qw(:sql_types);

$dbh = DBI->connect("dbi:Oracle:","sys","abc123",
                                        { AutoCommit => 1, PrintError => 1, RaiseError => 0 ,ora_session_mode => 2})
                                        or die("DB connect error! \n");

#$sql = "select * from TAB";

$sql = 'create user zhangxu identified by zx6819453
                default tablespace OPENKORE
                temporary tablespace TEMP_OPENKORE'
;
$sth = $dbh->prepare($sql);

$sth->execute() or die("error!");

$sql = 'grant connect,resource,dba to zhangxu';

$sth = $dbh->prepare($sql);

$sth->execute() or die("error!");



$sth->finish;
$dbh->disconnect();
exit 0;


阅读(1950) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~