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

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

SQLite (32-bit) 軟體圖示 SQLite (32-bit) 3.21.0 (32-bit) 資料更新 2017-10-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-3210000.zip · 連結指向軟體原廠

版本紀錄

再看 5 筆

看完整版本清單

這一版改了什麼

What's new in this version:

- Take advantage of the atomic-write capabilities in the F2FS filesystem when available, for greatly reduced transaction overhead. This currently requires the SQLITE_ENABLE_BATCH_ATOMIC_WRITE compile-time option
- Allow ATTACH and DETACH commands to work inside of a transaction
- Allow WITHOUT ROWID virtual tables to be writable if the PRIMARY KEY contains exactly one column
-The "fsync()" that occurs after the header is written in a WAL reset now uses the sync settings for checkpoints. This means it will use a "fullfsync" on macs if PRAGMA checkpoint_fullfsync set on
-The sqlite3_sourceid() function tries to detect if the source code has been modified from what is checked into version control and if there are modifications, the last four characters of the version hash are shown as "alt1" or "alt2". The objective is to detect accidental and/or careless edits. A forger can subvert this feature
-Improved de-quoting of column names for CREATE TABLE AS statements with an aggregate query on the right-hand side
-Fewer "stat()" system calls issued by the unix VFS
-Enhanced the LIKE optimization so that it works with an ESCAPE clause
-Enhanced PRAGMA integrity_check and PRAGMA quick_check to detect obscure row corruption that they were formerly missing. Also update both pragmas so that they return error text rather than SQLITE_CORRUPT when encountering corruption in records
- The query planner now prefers to implement FROM-clause subqueries using co-routines rather using the query flattener optimization. Support for the use of co-routines for subqueries may no longer be disabled
- Pass information about !=, IS, IS NOT, NOT NULL, and IS NULL constraints into the xBestIndex method of virtual tables
- Enhanced the CSV virtual table so that it accepts the last row of input if the final new-line character is missing
- Remove the rarely-used "scratch" memory allocator. Replace it with the SQLITE_CONFIG_SMALL_MALLOC configuration setting that gives SQLite a hint that large memory allocations should be avoided when possible
- Added the swarm virtual table to the existing union virtual table extension
- Added the sqlite_dbpage virtual table for providing direct access to pages of the database file. The source code is built into the amalgamation and is activated using the -DSQLITE_ENABLE_DBPAGE_VTAB compile-time option
- Add a new type of fts5vocab virtual table - "instance" - that provides direct access to an FTS5 full-text index at the lowest possible level
- Remove a call to rand_s() in the Windows VFS since it was causing problems in Firefox on some older laptops
- The src/shell.c source code to the command-line shell is no longer under version control. That file is now generated as part of the build process
- Miscellaneous microoptimizations reduce CPU usage by about 2.1%

Bug fixes:
- Fix a faulty assert() statement discovered by OSSFuzz
- Fix an obscure memory leak in sqlite3_result_pointer()
- Avoid a possible use-after-free error by deferring schema resets until after the query planner has finished running
- Only use indexes-on-expressions to optimize ORDER BY or GROUP BY if the COLLATE is correct
- Fix an assertion fault that was coming up when the expression in an index-on-expressions is really a constant
- Fix an assertion fault that could occur following PRAGMA reverse_unordered_selects
- Fix a segfault that can occur for queries that use table-valued functions in an IN or EXISTS subquery
- Fix a potential integer overflow problem when compiling a particular horrendous common table expression. This was another problem discovered by OSSFuzz
- Fix a potential out-of-bound read when querying a corrupt database file, a problem detected by Natalie Silvanovich of Google Project Zero