设为首页 加入收藏

TOP

Perl脚本访问Greenplum数据库安装指导(三)
2015-07-24 10:52:28 来源: 作者: 【 】 浏览:3
Tags:Perl 脚本 访问 Greenplum 数据库 安装 指导
assword 密码 unless(@ARGV == 3) { die "Usage: $0 dbname dbuserpassword\n"; } #接收传入的参数 my$dbname = $ARGV[0]; my$dbuser = $ARGV[1]; my$password =$ARGV[2]; my $sth; my$col_num; my @cols; my@row_ary; my $i; my $dbh =DBI->connect("dbi:ODBC:$dbname",$dbuser,$password, {AutoCommit => 0, RaiseError => 0, PrintError => 0,} ) or die"Can't connect to Greenplum database: $DBI::errstr\n"; $sth =$dbh->prepare("select * from hello1"); $sth->execute(); # Thenumber of columns $col_num= $sth->{NUM_OF_FIELDS}; # outputcolumns @cols = @{$sth->{NAME}}; printjoin("\t",@cols),"\n"; while (@row_ary = $sth->fetchrow_array ) { for($i=0; $i<$col_num; $i++){ my $len = length $cols[$i] ; printf "%-${len}s\t",$row_ary[$i]; } print "\n"; } $sth->finish; $dbh->disconnect(); exit 0;

(2) 测试过程:

linux-82:/etc/unixODBC # perl hellokitty.plGreenplumDSN noas noas

id name

2 hello2

1 hello1

3 hello3

?

首页 上一页 1 2 3 4 5 6 下一页 尾页 3/6/6
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇怎样收集EBS各种相关业务的表的数.. 下一篇PfileVSSpfile(MOSNote249664.1)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·PostgreSQL 索引 - (2025-12-25 22:20:43)
·MySQL Node.js 连接 (2025-12-25 22:20:41)
·SQL 撤销索引、表以 (2025-12-25 22:20:38)
·Linux系统简介 (2025-12-25 21:55:25)
·Linux安装MySQL过程 (2025-12-25 21:55:22)