[問題] DBI SELECT 一問
問題如下!
###########################
前面宣告省略...
$q=qq[ SELECT `content` FROM A_Table ];
$sth=$dbh->prepare($q);
unless($sth->execute) { die "$!\n"; }
while(my $content = $sth->fetchrow_array()){
...
}
或是用
my( $content );
$sth->bind_columns( \$content );
while($sth->fetch()){
...
}
的方式讀取資料庫中的資料時!
因為這個table有很多資料!
而全部的`content`加起來所佔空間不小!
本來我以為$sth->fetch()和$sth->fetchrow_array()
是類似filehandle一樣,並不會佔用大量的空間!
但好像是我誤解了!只要執行這個程式!
發現連unless($sth->execute) { die "$!\n"; }
都沒執行完,就佔去很大的記憶體空間~
所以我想問有沒有辦法可以依序地讀一筆資料的`content`出來處理
直到讀完整個資料庫!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.245.199
→
04/15 17:48, , 1F
04/15 17:48, 1F
→
04/20 20:01, , 2F
04/20 20:01, 2F
→
04/20 20:02, , 3F
04/20 20:02, 3F
Perl 近期熱門文章
PTT數位生活區 即時熱門文章