我假设你有AutoCommit => 0
连接通话,因为以下工作:
#!/usr/bin/perl use strict; use warnings; use DBI; my $dbh = DBI->connect('dbi:SQLite:test.db', undef, undef, { RaiseError => 1, AutoCommit => 1} ); $dbh->do('VACUUM'); $dbh->disconnect;
你不必放弃交易能够VACUUM
:您可以使用这样下AutoCommit
被开启VACUUM
和之后VACUUM
的AutoCommit
状态恢复到不管它是什么.如果未设置,请添加错误检查RaiseError
.
sub do_vacuum { my ($dbh) = @_; local $dbh->{AutoCommit} = 1; $dbh->do('VACUUM'); return; }
叫它:
do_vacuum($dbh);