我已经使用 DBI 模块编写了这段代码,这是代码
#!/usr/local/bin/perl -w
use DBI;
use strict;
# Open a connection
my $dbh = DBI->connect("dbi:DB2:awdrt", "db2inst1", "db2inst1", {RaiseError => 1});
# use VALUES to retrieve value from special register
my $stmt = "select RTRIM(substr(A.TBSP_NAME,1,30)),A.TBSP_TYPE as TYPE,A.TBSP_FREE_PAGES as FREE,B.CONTAINER_NAME as CON_PATH from SYSIBMADM.TBSP_UTILIZATION A ,SYSIBMADM.CONTAINER_UTILIZATION B where A.TBSP_ID=B.TBSP_ID and A.TBSP_AUTO_RESIZE_ENABLED=0 with UR";
my $sth = $dbh->prepare($stmt);
$sth->execute();
# associate variables with output columns...
my ($col1,$col,$col3,$col4);
$sth->bind_col(1,\$col1);
$sth->bind_col(3,\$col3);
$sth->bind_col(4,\$col4);
while ($sth->fetch) { if ($col3 <= 2000){
print "$col1 has $col3 pages with container $col4\n";}
}
$sth->finish();
$dbh->disconnect();
这是 O/p :
TRANS_DATA has 1616 pages with container /adrst/bdts/trans_data_container
MASTER_INDEX has 1872 pages with container /adrst/bdts/master_index_container
TRANSACTION_INDEX has 1856 pages with container /adrst/bdts/transaction_index_container
执行查询时的表数据为:
1 TYPE FREE CON_PATH
------------------------------ ---------- -------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
USERSPACE1 DMS 15056 /adrst/bdts/userspc_container
USERSPACE1 DMS 15056 /adrst/bdts/userspc_container1
MASTER DMS 3584 /adrst/bdts/master_container
TRANS_DATA DMS 1616 /adrst/bdts/trans_data_container
MASTER_INDEX DMS 1872 /adrst/bdts/master_index_container
TRANSACTION_INDEX DMS 1856 /adrst/bdts/transaction_index_container
TEMP_SYS DMS 2192 /adrst/bdts/temp_sys_container
AUDIT_DATA DMS 3360 /adrst/bdts/audit_data_container
TEMP_USR DMS 2672 /adrst/bdts/temp_usr_container
TSASNCA DMS 2840 /home/db2inst1/db2inst1/NODE0000/SQL00002/TSASNCA
TSASNUOW DMS 2880 /home/db2inst1/db2inst1/NODE0000/SQL00002/TSASNUOW
TSASNAA DMS 3712 /home/db2inst1/db2inst1/NODE0000/SQL00002/TSASNAA
TSCDADDRESSMASTER DMS 2048 /home/db2inst1/db2inst1/NODE0000/SQL00002/CDADDRESSMASTER
13 record(s) selected.
我在这里尝试的基本上是报告少于 2000 页的表空间,现在我的问题是没有这个模块我该怎么做,什么是更好的选择,哈希、正则表达式、grep?如果是这样,我需要将三列报告为 o/p ,我该如何使用这些或任何可能使用的东西来做到这一点?
帮助表示赞赏......