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

SQLite 64位是什麼?輕量資料庫怎麼用

SQLite (64-bit) 軟體圖示 SQLite (64-bit) 3.25.0 (64-bit) 資料更新 2018-09-16 閱讀約 5 分鐘

寫個小工具或網站,需要把資料存下來,但想到要裝 MySQL 或 SQL Server 就頭痛——安裝程式好幾百 MB,設定服務、開 port、設帳號密碼,光前置作業就耗掉半天。你只是想讓程式把資料寫進檔案、之後能查得出來,不想為此養一台資料庫伺服器。

用 Excel 或 CSV 檔存資料,一開始很直覺,但資料一多、要跨表格比對或做條件篩選時,就開始卡。這類工具的切入點是「嵌入式資料庫」:不需要獨立伺服器,資料全部存在單一檔案裡,程式直接讀寫這個檔案,零設定、免安裝、離線可用。你要的只是把 SQL 查詢能力帶進你的應用程式,而不是管理一套資料庫系統。

01SQLite 64位能做什麼?

它是一個嵌入式資料庫引擎,不需要獨立伺服器,資料存在單一檔案中。你可以用 SQL 指令建立資料庫、建立表格、插入資料、查詢資料,支援大部分 SQL 標準,包括子查詢、JOIN 和觸發器。適合應用程式的本地儲存、行動裝置和嵌入式系統,例如桌面軟體的設定檔、遊戲存檔、分析工具的暫存資料。

02怎麼建立資料庫和表格?

下載 ZIP 檔解壓縮後,執行 sqlite3.exe,輸入 `sqlite3 database_name.db` 就會建立一個新的資料庫檔案。建立表格用 `CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);`,插入資料用 `INSERT INTO users (name) VALUES ('John Doe');`,查詢用 `SELECT * FROM users;`。整個過程不需要任何設定。

03支援哪些 SQL 功能?

支援大部分 SQL 標準,包括子查詢、JOIN、觸發器,也具備完整的 ACID 交易保證,確保資料完整性。資料庫最大可達 281TB,但實際效能會依硬體和查詢複雜度而異。官方文件相當完整,語法與其他關聯式資料庫類似,學過 SQL 的人可以很快上手。

04資料庫檔案可以多大?

官方說明指出最大可達 281TB,但效能會隨資料量增加而下降。對一般應用程式的本地儲存來說,幾 GB 到幾十 GB 都還算常見使用範圍。如果資料量極大且查詢複雜,效能衰減會很明顯,這套軟體不是為超大規模資料設計的。

05怎麼匯出資料?

在 sqlite3 命令列中,先輸入 `.mode csv` 設定輸出格式,再輸入 `.output file.csv` 指定輸出檔案,最後執行 `SELECT * FROM users;`,查詢結果就會寫入 CSV 檔案。要回到螢幕輸出時,輸入 `.output stdout` 即可。這是內建功能,不需要額外工具。

06需要安裝嗎?

不需要。下載 ZIP 檔後解壓縮到任意資料夾就能執行,也可以把資料夾加入系統的 PATH 環境變數,方便從任何位置呼叫 sqlite3.exe。整個過程完全離線運作,不需要網路連線,也沒有任何背景服務或常駐程式。

07免費嗎?

是,SQLite 採用公共領域授權,完全免費,任何人可以無限制使用,包含商業用途。不過,如果你需要加密功能,官方提供的 SQLite Encryption Extension(SEE)需要付費授權;另一個選擇是開源的 SQLCipher,但這不在官方預設支援範圍內,需要自行整合。

08多人同時使用適合嗎?

不適合。SQLite 設計用於本地儲存,雖然支援多個連線,但不是為高流量並發環境最佳化。多人同時寫入時可能遇到鎖定問題,官方說明也明確指出它不適合高並發環境。如果你的應用需要多人同時讀寫,應該考慮 MySQL 或 PostgreSQL 這類完整 RDBMS。

09有圖形介面嗎?

SQLite 本身沒有圖形介面,只有命令列工具。官方說明提到可以搭配第三方 GUI 工具,例如 DB Browser for SQLite 或 SQLiteStudio,這些工具提供圖形化的資料庫結構檢視,方便瀏覽表格、執行查詢、匯入匯出資料。如果你習慣視覺化操作,需要另外下載這些工具。

10需要使用者管理嗎?

不需要,SQLite 沒有內建認證或使用者管理功能。資料庫就是一個檔案,任何能存取該檔案的人都能讀寫全部內容。如果你的應用需要區分使用者權限,必須在應用層自行實作,或改用有內建帳號管理的資料庫系統。這對單機應用不是問題,但對多人共享的環境就是限制。

11資料量很大適合嗎?

不適合。官方說明指出,資料量很大時效能會下降,而且不適合大規模多使用者應用。它擅長的是單一使用者或嵌入式場景,例如應用程式本地儲存、行動裝置、小型工具。如果你的資料預期會成長到數十 GB 以上,或需要多人同時查詢,應該評估其他資料庫方案。

下載與官方連結

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

sqlite-dll-win64-x64-3250000.zip · 788.48 KB · 連結指向軟體原廠

版本紀錄

再看 5 筆

看完整版本清單

這一版改了什麼

What's new in this version:

- Add support for window functions
- Use a separate mutex on every inode in the unix VFS, rather than a single mutex shared among them all, for slightly better concurrency in multi-threaded environments
- Enhance the PRAGMA integrity_check command for improved detection of problems on the page freelist
- Output infinity as 1e999 in the ".dump" command of the command-line shell
- Added the SQLITE_FCNTL_DATA_VERSION file-control
- Added the Geopoly module

Enhancements the ALTER TABLE command:
- Add support for renaming columns within a table using ALTER TABLE table RENAME COLUMN oldname TO newname
- Fix table rename feature so that it also updates references to the renamed table in triggers and views

Query optimizer improvements:
- Avoid unnecessary loads of columns in an aggregate query that are not within an aggregate function and that are not part of the GROUP BY clause
- The IN-early-out optimization: When doing a look-up on a multi-column index and an IN operator is used on a column other than the left-most column, then if no rows match against the first IN value, check to make sure there exist rows that match the columns to the right before continuing with the next IN value
- Use the transitive property to try to propagate constant values within the WHERE clause. For example, convert "a=99 AND b=a" into "a=99 AND b=99"

Bug fixes:
- The ORDER BY LIMIT optimization might have caused an infinite loop in the byte code of the prepared statement under very obscure circumstances, due to a confluence of minor defects in the query optimizer
- On an UPSERT when the order of constraint checks is rearranged, ensure that the affinity transformations on the inserted content occur before any of the constraint checks
- Avoid using a prepared statement for ".stats on" command of the CLI after it has been closed by the ".eqp full" logicc
- The LIKE optimization was generating incorrect byte-code and hence getting the wrong answer if the left-hand operand has numeric affinity and the right-hand-side pattern is '/%' or if the pattern begins with the ESCAPE character