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

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

SQLite (32-bit) 軟體圖示 SQLite (32-bit) 3.24.0 (32-bit) 資料更新 2018-06-05 閱讀約 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-3240000.zip · 409.6 KB · 連結指向軟體原廠

版本紀錄

再看 5 筆

看完整版本清單

這一版改了什麼

What's new in this version:

- Add support for PostgreSQL-style UPSERT
- Add support for auxiliary columns in r-tree tables
- Add C-language APIs for discovering SQL keywords used by SQLite: sqlite3_keyword_count(), sqlite3_keyword_name(), and sqlite3_keyword_check()
- Add C-language APIs for dynamic strings based on the sqlite3_str object
- Enhance ALTER TABLE so that it recognizes "true" and "false" as valid arguments to DEFAULT
- Add the sorter-reference optimization as a compile-time option. Only available if compiled with SQLITE_ENABLE_SORTER_REFERENCES
- Improve the format of the EXPLAIN QUERY PLAN raw output, so that it gives better information about the query plan and about the relationships between the various components of the plan
- Added the SQLITE_DBCONFIG_RESET_DATABASE option to the sqlite3_db_config() API

CLI Enhancements:
- Automatically intercepts the raw EXPLAIN QUERY PLAN output and reformats it into an ASCII-art graph
- Lines that begin with "#" and that are not in the middle of an SQL statement are interpreted as comments
- Added the --append option to the ".backup" command
- Added the ".dbconfig" command

Performance:
- UPDATE avoids writing database pages that do not actually change. For example, "UPDATE t1 SET x=25 WHERE y=?" becomes a no-op if the value in column x is already 25. Similarly, when doing UPDATE on records that span multiple pages, only write the subset of pages that contain the changed value(s)
- Queries that use ORDER BY and LIMIT now try to avoid computing rows that cannot possibly come in under the LIMIT. This can greatly improve performance of ORDER BY LIMIT queries, especially when the LIMIT is small relative to the number of unrestricted output rows
- The OR optimization is allowed to proceed even if the OR expression has also been converted into an IN expression. Uses of the OR optimization are now also more clearly shown in the EXPLAIN QUERY PLAN output
- The query planner is more aggressive about using automatic indexes for views and subqueries for which it is not possible to create a persistent index
- Make use of the one-pass UPDATE and DELETE query plans in the R-Tree extension where appropriate
- Performance improvements in the LEMON-generated parser

Bug fixes:
- For the right-hand table of a LEFT JOIN, compute the values of expressions directly rather than loading precomputed values out of an expression index as the expression index might not contain the correct value. Ticket 7fa8049685b50b5aeb0c2
- Do not attempt to use terms from the WHERE clause to enable indexed lookup of the right-hand table of a LEFT JOIN. Ticket 4ba5abf65c5b0f9a96a7a
- Fix a memory leak that can occur following a failure to open error in the CSV virtual table
- Fix a long-standing problem wherein a corrupt schema on the sqlite_sequence table used by AUTOINCREMENT can lead to a crash. Ticket d8dc2b3a58cd5dc2918a1
- Fix the json_each() function so that it returns valid results on its "fullkey" column when the input is a simple value rather than an array or object.

Hashes:
- SQLITE_SOURCE_ID: "2018-06-04 19:24:41 c7ee0833225bfd8c5ec2f9bf62b97c4e04d03bd9566366d5221ac8fb199a87ca"
- SHA3-256 for sqlite3.c: 0d384704e1c66026228336d1e91771d295bf688c9c44c7a44f25a4c16c26ab3c