這是歷史版本頁面 — 看 SQLite (32-bit) 最新版本

SQLite 免安裝單檔資料庫能做什麼

SQLite (32-bit) 軟體圖示 SQLite (32-bit) 3.20.1 (32-bit) 資料更新 2017-08-25 閱讀約 5 分鐘

寫程式或處理資料時,常常會遇到一個尷尬的處境:只是想存一點資料,例如記帳、管理書單、收集爬蟲結果,但打開 Excel 很快就卡住,裝 MySQL 又覺得殺雞用牛刀。光是安裝資料庫伺服器、設定帳號密碼、處理連線,就耗掉大半時間,最後連資料都還沒開始建。

一般人的直覺是「那就用 Excel 吧」,但資料一多、要下 SQL 查詢時就力不從心;另一條路是裝完整的資料庫系統,但伺服器架構對單機小專案來說既笨重又難維護。這類工具切入的點是:把整個資料庫引擎直接嵌進你的程式裡,不需要另外開伺服器,資料全部存在一個檔案中,隨身帶著走。

01SQLite 到底是什麼,跟一般資料庫有什麼不一樣

它是一個嵌入式資料庫引擎,以函式庫的形式直接連結到你的程式裡,不需要安裝伺服器、不需要設定連線。整個資料庫就是一個單獨的磁碟檔案,程式透過 API 或內建的 sqlite3.exe 指令介面來操作。因為零設定、免管理,常被當成應用程式的檔案格式來用。

02這套軟體能處理多大的資料量

官方說明指出它支援 TB 等級的資料庫,以及 GB 等級的字串和 BLOB 資料。不過要注意,這是在理想條件下的上限,實際效能會受到硬體、查詢複雜度和使用方式的影響。如果你的資料量在數 GB 以內,通常不會遇到問題,但超過這個規模就要謹慎評估。

03它支援哪些 SQL 功能,會不會很多語法不能用

它實作了完整的 SQL,並包含進階功能,例如部分索引(partial indexes)和通用資料表表達式(common table expressions)。也就是說,一般常用的 SELECT、JOIN、子查詢都沒問題,一些現代 SQL 的進階語法也有支援。但官方沒有列出省略了哪些功能,如果你需要特定的資料庫功能,最好先查文件確認。

04多人同時使用同一個資料庫檔案,會不會有問題

官方明確指出它不適合大型資料庫,而且並行寫入的能力有限。它的設計是單一檔案、單一程序為主,雖然支援多人讀取,但同時有多個寫入需求時會鎖定檔案,造成等待或衝突。如果你的應用場景是多人同時寫入,這套軟體不是合適的選擇。

05它需要安裝嗎,還是下載就能用

不需要安裝。下載 ZIP 檔後解壓縮,執行資料夾裡的 sqlite3.exe 就能啟動指令介面。整個程式碼小於 500KiB,對系統資源的占用很低,也不需要管理員權限。這對想快速測試或把資料庫檔案帶著走的人來說很方便。

06我不會寫程式,只想要一個工具來管理資料,適合用嗎

它本身是給開發者用的函式庫,操作方式是透過指令介面輸入 SQL 指令,沒有圖形化的管理介面。如果你不會寫程式、也不想學 SQL,用起來會很吃力。這種情況比較適合找圖形化的資料庫管理工具,而不是直接用這套軟體。

07寫桌面應用程式的人,用這套軟體適合嗎

適合。因為它是嵌入式資料庫,不需要使用者另外安裝資料庫伺服器,對一般使用者來說負擔很小。資料存在單一檔案中,備份、搬移都很直覺。官方也提到它被廣泛部署在許多應用程式中,作為應用程式的檔案格式。如果你寫的是單機程式,這是一個務實的選擇。

08跟 MySQL 比起來,我該選哪一個

兩者的定位不同。MySQL 是完整的客戶端-伺服器架構,支援多人同時連線、具備使用者權限管理,適合網站或多人協作的系統。SQLite 是嵌入式、單一檔案、不需要伺服器,適合單機應用或資料量不大、並行寫入需求低的場景。如果你的需求是單機使用,SQLite 會簡單很多;如果需要多人連線和權限控管,MySQL 才是正解。

09我需要帳號密碼管理,這套軟體有辦法做到嗎

沒有。官方明確指出它缺乏內建的使用者認證機制,也沒有客戶端-伺服器架構。任何能存取資料庫檔案的人,都能直接讀取或修改內容。如果你的應用需要區分使用者權限,或資料需要透過網路讓多人存取,這套軟體不適合,應該考慮有完整權限管理的資料庫系統。

10它的評分人數很少,這代表什麼

在提供的資料中,它只有 29 人評分,分數是 7.68/10。相較之下,MySQL 有 1021 人評分。評分人數少不代表軟體不好,但代表樣本數不足,參考價值有限。這套軟體在開發者社群中其實很普及,只是這個網站上的評分樣本較少。建議你參考官方文件和實際測試來判斷。

11這套軟體還在持續更新嗎

根據版本紀錄,從最早收錄的版本到最近一次更新,時間跨度很大,且近 12 個月更新了 9 次、近 24 個月更新了 20 次。從這個頻率來看,它仍然在積極維護中。對於需要長期穩定的專案來說,持續更新是一個正面的訊號。

12資料庫檔案可以跨平台使用嗎

可以。官方說明指出它支援 Android、iOS、Linux、Mac、Windows 等多個平台,而且整個資料庫就是一個跨平台的磁碟檔案。也就是說,你在 Windows 上建立的資料庫檔案,可以直接複製到 Mac 或 Linux 上使用,不需要轉換格式。這對需要在不同裝置間搬移資料的人來說很方便。

下載與官方連結

前往官方網站 下載 SQLite (32-bit)

sqlite-dll-win32-x86-3200100.zip · 409.6 KB · 連結指向軟體原廠

版本紀錄

再看 5 筆

看完整版本清單

這一版改了什麼

What's new in this version:

- Fix a potential memory leak in the new sqlite3_result_pointer() interface.

Changes carried forward from version 3.20.0:
- Update the text of error messages returned by sqlite3_errmsg() for some error codes
- Add new pointer passing interfaces
- Backwards-incompatible changes to some extensions in order to take advantage of the improved security offered by the new pointer passing interfaces: a. Extending FTS5 → requires sqlite3_bind_pointer() to find the fts5_api pointer
- carray(PTR,N) → requires sqlite3_bind_pointer() to set the PTR parameter
- remember(V,PTR) → requires sqlite3_bind_pointer() to set the PTR parameter
- Added the SQLITE_STMT virtual table extension
- Added the COMPLETION extension - designed to suggest tab-completions for interactive user interfaces. This is a work in progress. Expect further enhancements in future releases
- Added the UNION virtual table extension
- The built-in date and time functions have been enhanced so that they can be used in CHECK constraints, in indexes on expressions, and in the WHERE clauses of partial indexes, provided that they do not use the 'now', 'localtime', or 'utc' keywords. Futher information
- Added the sqlite3_prepare_v3() and sqlite3_prepare16_v3() interfaces with the extra "prepFlags" parameters
- Provide the SQLITE_PREPARE_PERSISTENT flag for sqlite3_prepare_v3() and use it to limit lookaside memory misuse by FTS3, FTS5, and the R-Tree extension
- Added the PRAGMA secure_delete=FAST command. When secure_delete is set to FAST, old content is overwritten with zeros as long as that does not increase the amount of I/O. Deleted content might still persist on the free-page list but will be purged from all b-tree pages
- Enhancements to the command-line shell: a. Add support for tab-completion using the COMPLETION extension, for both readline and linenoise
- Add the ".cd" command
- Enhance the ".schema" command to show the schema of all attached databases
- Enhance ".tables" so that it shows the schema names for all attached if the name is anything other than "main"
- The ".import" command ignores an initial UTF-8 BOM
- Added the "--newlines" option to the ".dump" command to cause U+000a and U+000d characters to be output literally rather than escaped using the replace() function
- Query planner enhancements: a. When generating individual loops for each ORed term of an OR scan, move any constant WHERE expressions outside of the loop, as is done for top-level loops
- The query planner examines the values of bound parameters to help determine if a partial index is usable
- When deciding between two plans with the same estimated cost, bias the selection toward the one that does not use the sorter
- Evaluate WHERE clause constraints involving correlated subqueries last, in the hope that they never have be evaluated at all
- Do not use the flattening optimization for a sub-query on the RHS of a LEFT JOIN if that subquery reads data from a virtual table as doing so prevents the query planner from creating automatic indexes on the results of the sub-query, which can slow down the query
- Add SQLITE_STMTSTATUS_REPREPARE, SQLITE_STMTSTATUS_RUN, and SQLITE_STMTSTATUS_MEMUSED options for the sqlite3_stmt_status() interface
- Provide PRAGMA functions for PRAGMA integrity_check, PRAGMA quick_check, and PRAGMA foreign_key_check
- Add the -withoutnulls option to the TCL interface eval method
- Enhance the sqlite3_analyzer.exe utility program so that it shows the number of bytes of metadata on btree pages
- The SQLITE_DBCONFIG_ENABLE_QPSG run-time option and the SQLITE_ENABLE_QPSG compile-time option enable the query planner stability guarantee
- Miscellaneous optimizations result in a 2% reduction in CPU cycles used

Bug Fixes:
- Fix the behavior of sqlite3_column_name() for queries that use the flattening optimization so that the result is consistent with other queries that do not use that optimization, and with PostgreSQL, MySQL, and SQLServer
- Fix the query planner so that it knows not to use automatic indexes on the right table of LEFT JOIN if the WHERE clause uses the IS operator
- Ensure that the query planner knows that any column of a flattened LEFT JOIN can be NULL even if that column is labeled with "NOT NULL"
- Fix rare false-positives in PRAGMA integrity_check when run on a database connection with attached databases
- Fix a bug (discovered by OSSFuzz) that causes an assertion fault if certain dodgy CREATE TABLE declarations are used