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

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

SQLite (64-bit) 軟體圖示 SQLite (64-bit) 3.44.0 (64-bit) 資料更新 2023-11-01 閱讀約 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-3440000.zip · 連結指向軟體原廠

版本紀錄

再看 5 筆

看完整版本清單

這一版改了什麼

What's new in this version:

- Aggregate functions can now include an ORDER BY clause after their last parameter. The arguments to the function are processed in the order specified. This can be important for functions like string_agg() and json_group_array().
- Add support for the concat() and concat_ws() scalar SQL functions, compatible with PostgreSQL, SQLServer, and MySQL
- Add support for the string_agg() aggregate SQL function, compatible with PostgreSQL and SQLServer
- New conversion letters on the strftime() SQL function: %e %F %I %k %l %p %P %R %T %u
- Add new C-language APIs: sqlite3_get_clientdata() and sqlite3_set_clientdata().
- Many errors associated with CREATE TABLE are now raised when the CREATE TABLE statement itself is run, rather than being deferred until the first time the table is actually used.
- The PRAGMA integrity_check command now verifies the consistency of the content in various built-in virtual tables using the new xIntegrity method. This works for the FTS3, FTS4, FTS5, RTREE, and GEOPOLY extensions.
- The SQLITE_DBCONFIG_DEFENSIVE setting now prevents PRAGMA writable_schema from being turned on. Previously writable_schema could be turned on, but would not actually allow the schema to be writable. Now it simply cannot be turned on.
- Tag the built-in FTS3, FTS4, FTS5, RTREE, and GEOPOLY virtual tables as SQLITE_VTAB_INNOCUOUS so that they can be used inside of triggers in high-security deployments.
- The PRAGMA case_sensitive_like statement is deprecated, as its use when the schema contains LIKE operators can lead to reports of database corruption by PRAGMA integrity_check
- SQLITE_USE_SEH (Structured Exception Handling) is now enabled by default whenever SQLite is built using the Microsoft C compiler. It can be disabled using -DSQLITE_USE_SEH=0

Query planner optimizations:
- In partial index scans, if the WHERE clause implies a constant value for a table column, replace occurrences of that table column with the constant. This increases the likelihood of the partial index being a covering index.
- Disable the view-scan optimization (added in version 3.42.0 - item 1c) as it was causing multiple performance regressions. In its place, reduce the estimated row count for DISTINCT subqueries by a factor of 8.
- SQLite now performs run-time detection of whether or not the underlying hardware supports "long double" with precision greater than "double" and uses appropriate floating-point routines depending on what it discovered.
- The CLI for Windows now defaults to using UTF-8 for both input and output on platforms that support it. The --no-utf8 option is available to disable UTF8 support.