【问题标题】:SQLite page_size change using vacuum inVB.netSQLite page_size 在VB.net中使用真空改变
【发布时间】:2012-09-23 02:44:24
【问题描述】:

引用自 SQLite 网页 " 如果 page_size pragma 用于在运行 VACUUM 命令之前指定新的页面大小,并且如果数据库未处于 WAL 日志模式,则 VACUUM 会将页面大小更改为新值。"

我的 SQLite 3.7 数据库在 1024 页面大小上运行,由于我使用 Windows,我想我会尝试 4096 看看会发生什么。我一生都无法改变它,有人可以看看我的代码并告诉我我在哪里搞砸了,谢谢

 Dim connection As New SQLite.SQLiteConnection(conectionString)
            connection.Open()
            Dim oMainQueryR As New SQLite.SQLiteCommand
            oMainQueryR.Connection = connection
            oMainQueryR.CommandText = ("PRAGMA page_size=4096")
            oMainQueryR.ExecuteNonQuery()

            oMainQueryR = New SQLite.SQLiteCommand
            oMainQueryR.Connection = connection
            oMainQueryR.CommandText = ("vacuum")
            oMainQueryR.ExecuteNonQuery()
            connection.Close()

vacuum 命令运行正常,只是它重置了页面大小,并且我没有运行 WAL

【问题讨论】:

  • 在sqlite3.exe中运行这些命令是否有效?
  • 我正在使用 Dll,我对 exe 的第一件事一无所知
  • 我不认为我可以使用 shell,因为数据库是加密的。但我会试一试。

标签: vb.net sqlite system.data.sqlite


【解决方案1】:

问题是加密,把它去掉,代码如下所示。感谢让我思考的C.L!如果您没有加密,则只需删除对 ChangePasswords 的 2 个引用。有趣的是,将页面大小从默认的 1024 设置为 4096,数据库增长了约 10%。

        Dim connection As New SQLite.SQLiteConnection(conectionString)
        connection.Open()
        connection.ChangePassword("")
        Dim oMainQueryR As New SQLite.SQLiteCommand
        oMainQueryR.Connection = connection
        oMainQueryR.CommandText = ("PRAGMA page_size=") & Val(Me.TextBox254.Text) & "; vacuum"
        oMainQueryR.ExecuteNonQuery()
        connection.ChangePassword(previous password)

        connection.Close()

【讨论】:

    猜你喜欢
    • 2011-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多