简体   繁体   English

使用 TCL 更改 SQLite 上的 journal_mode

[英]Change journal_mode on SQLite with TCL

I want to upgrade my inserts velocity and I read about modifying the journal mode.我想升级我的插入速度并且我阅读了有关修改日志模式的信息。 How can I do it on TCL code?我怎样才能在 TCL 代码上做到这一点? Thanks!谢谢!

Assuming db is your SQLite database handle, you just issue a PRAGMA like this:假设db是您的 SQLite 数据库句柄,您只需像这样发出PRAGMA

db eval {
    PRAGMA journal_mode = WAL;
}

If you care a lot about speed and not much about integrity (I have one application where this is the case) then you're probably sufficiently well served by just turning off synchronization while you're doing all the inserts.如果您非常关心速度而不是完整性(我有一个应用程序就是这种情况),那么您在执行所有插入操作时只需关闭同步就可以得到足够好的服务。

db eval {
    PRAGMA synchronous = OFF;
}

Doing this makes writing to an SQLite database about as fast as just writing directly to your own binary file, but it is only a good idea in some cases.这样做使得写入 SQLite 数据库的速度与直接写入您自己的二进制文件一样快,但在某些情况下这只是一个好主意。 (My case alluded to above is where the writing process is what made the database and where anything other than total success is not useful to users. It's definitely not a normal database use-case!) (上面提到的我的案例是编写过程是数据库的组成部分,除了完全成功之外,其他任何事情对用户都没有用。这绝对不是正常的数据库用例!)

Note that pragmas are per DB handle/connection.请注意,pragma 是针对每个 DB 句柄/连接的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在C#中更改Sqlite数据库的“ journal_mode” - How to change “journal_mode” of a Sqlite database in C# 如何在Windows中将SQLite DB journal_mode更改为WAL? - How to change SQLite DB journal_mode to WAL in Windows? Android SQLite - 改变 journal_mode - Android SQLite - changing journal_mode SQLite pragma (journal_mode) 语句持久化 - SQLite pragma (journal_mode) statement persistence 检查SQLite是否使用journal_mode = WAL或journal_mode = DELETE的函数 - function to check if SQLite is using journal_mode=WAL or journal_mode=DELETE SQLite:使用journal_mode = wal和sync = normal进行Fsyncing - SQLite: Fsyncing with journal_mode = wal and synchronous = normal PHP SQLite PRAGMA journal_mode = wal和只读用户 - PHP SQLite PRAGMA journal_mode = wal and readonly users 在iOS中使用SQLite PRAGMA同步= OFF和journal_mode = MEMORY进行更新的最坏情况行为 - Worst case behavior for updates using SQLite PRAGMA synchronous = OFF and journal_mode = MEMORY in iOS SqLite 数据库在 unicode 和 PRAGMA journal_mode 设置时不会关闭 - SqLite database won't close when in unicode and PRAGMA journal_mode is set SQLite - 数据库被锁定在“PRAGMA journal_mode” - 错误仅针对某些 Android 设备 - SQLite - database is locked in "PRAGMA journal_mode" - error only for certain Android devices
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM