{ "version": "https://jsonfeed.org/version/1", "title": "SQLite", "description": "SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.", "home_page_url": "go/sqlite", "feed_url": "feed/sqlite.json", "icon": "https://cdn.v2ex.com/navatar/1700/0029/292_large.png?m=1645611998", "favicon": "https://cdn.v2ex.com/navatar/1700/0029/292_normal.png?m=1645611998", "items": [ { "author": { "url": "member/cj323", "name": "cj323", "avatar": "https://cdn.v2ex.com/gravatar/55d8713a4741083ba73747a518298a1f?s=73&d=retro" }, "url": "t/1153321", "date_modified": "2025-08-18T16:23:43+00:00", "content_html": "

\u6700\u8fd1\u5199\u4e86\u4e2a\u5bf9 sqlite \u6570\u636e\u5e93\u8bfb\u5199\u90fd\u6bd4\u8f83\u5927\u4e14\u9891\u7e41\u7684\u7a0b\u5e8f\uff0c\u8e29\u4e86\u4e00\u4e9b\u5751\u3002\u6700\u540e\u7528\u4e86\u5982\u4e0b\u914d\u7f6e\u6700\u5927\u5316 sqlite3 \u7684\u6027\u80fd\u3002

\n
PRAGMA journal_mode = WAL;\nPRAGMA busy_timeout = 5000;\nPRAGMA synchrOnous= NORMAL;\n
\n
    \n
  1. journal_mode = WAL\uff1a \u652f\u6301\u8bfb\u5199\u540c\u65f6\u8fdb\u884c\u3002\u9ad8\u5e76\u53d1\u4e0b\u63d0\u5347\u6700\u660e\u663e
  2. \n
  3. busy_timeout\uff1a\u53ef\u4ee5\u7f13\u89e3\u540c\u65f6\u591a\u5199\u5165\u65f6\u7684 SQLITE_BUSY \u62a5\u9519\u30025000 \u662f\u4e94\u79d2\u3002
  4. \n
  5. PRAGMA synchrOnous= NORMAL; \u51cf\u5c0f\u9ed8\u8ba4\u540c\u6b65\u9891\u7387
  6. \n
\n

\u5185\u5b58\u591f\u7528\u7684\u8bdd\u8fd8\u53ef\u4ee5\u8bbe\u7f6e\u8fd9\u4e24\u4e2a\u9009\u9879\u52a0\u5927\u5185\u5b58\u7f13\u5b58\u3002

\n
PRAGMA cache_size = 1000000000;\nPRAGMA temp_store = memory;\n
\n", "date_published": "2025-08-18T16:22:51+00:00", "title": "\u5206\u4eab\u9002\u5408\u9ad8\u5e76\u53d1\u573a\u666f\u7684 SQLite \u8bbe\u7f6e", "id": "t/1153321" }, { "author": { "url": "member/MrLonely", "name": "MrLonely", "avatar": "https://cdn.v2ex.com/avatar/a3d4/1bd8/127428_large.png?m=1735887226" }, "url": "t/884005", "title": "\u5728\u4ec0\u4e48\u60c5\u51b5\u4e0b\u4e00\u5b9a\u8981\u653e\u5f03 SQLite \u91c7\u7528 MySQL \u5462\uff1f", "id": "t/884005", "date_published": "2022-09-30T05:00:07+00:00", "content_html": "

\u73b0\u5728\u5728\u4e00\u5bb6\u5c0f\u516c\u53f8\u91cc\u5e2e\u5fd9\u505a\u4e00\u4e9b\u6570\u636e\u5904\u7406\uff0c\u91d1\u878d\u65b9\u9762\u7684\u3002\u6570\u636e\u90fd\u662f\u4ece\u4eba\u5de5\u5904\u7406\u8fc7\u7684 Excel \u91cc\u6765\u7684\u3002\u76ee\u524d\u6570\u636e\u653e\u8fdb SQLite \u91cc\u5927\u6982\u6570\u636e\u5e93\u6587\u4ef6\u5927\u5c0f\u5728 500MB \u5de6\u53f3\u3002\u540e\u7eed\u53ef\u80fd\u4f1a\u589e\u957f\u5230\u51e0\u767e GB \u3002

\n

\u56e0\u4e3a SQLite \u7b80\u5355\uff0c\u4e0d\u9700\u8981\u89e3\u51b3\u914d\u7f6e\uff0c\u7aef\u53e3\uff0c\u7528\u6237\u540d\uff0c\u7b49\u7b49\u590d\u6742\u95ee\u9898\u3002\u5373\u5f00\u5373\u7528\u3002

\n

\u90a3\u4ee5\u540e\u5230\u4e86\u4ec0\u4e48\u65f6\u5019\u5c31\u8be5\u4ece SQLite \u6362\u5230 MySQL \u4e86\u5462\uff1f\u6216\u8005\u6362\u5230 SQL Server \uff1f

\n" }, { "author": { "url": "member/join", "name": "join", "avatar": "https://cdn.v2ex.com/avatar/a372/457b/16318_large.png?m=1723696699" }, "url": "t/869820", "title": "SQLite \u80cc\u540e\u7684\u6545\u4e8b", "id": "t/869820", "date_published": "2022-07-31T14:23:13+00:00", "content_html": "
https://liyafu.com/2022-07-31-sqlite-untold-story/" }, { "author": { "url": "member/youthfire", "name": "youthfire", "avatar": "https://cdn.v2ex.com/avatar/8760/d018/33111_large.png?m=1714961788" }, "url": "t/866001", "title": "\u5e94\u8be5\u600e\u4e48\u7406\u89e3 rowid \u5728 sqlite \u4e2d\u7684\u4f7f\u7528", "id": "t/866001", "date_published": "2022-07-13T14:44:21+00:00", "content_html": "S.O \u4e0a\u6211\u8bb0\u5f97\u6709\u4e2a\u8d34
https://stackoverflow.com/questions/35876171/sqlite-rowid-after-deleting-rows
\u5176\u4e2d\u6709\u6bb5\u8bdd\u6211\u5370\u8c61\u5f88\u6df1
The data for rowid tables is stored as a B-Tree structure containing one entry for each table row, using the rowid value as the key. This means that retrieving or sorting records by rowid is fast. Searching for a record with a specific rowid, or for all records with rowids within a specified range is around twice as fast as a similar search made by specifying any other PRIMARY KEY or indexed value.
\u603b\u7ed3\u8d77\u6765\uff1arowid - \u4e5f\u5c31\u662f true primary key \u6027\u80fd\u4f18\u52bf\u5927

\u5728 Sqlite \u5b98\u7f51\u7684 rowid table \u4e2d\uff0c\u53c8\u662f\u8fd9\u4e48\u9610\u8ff0\u7684\uff1aIf the rowid is not aliased by INTEGER PRIMARY KEY then it is not persistent and might change. In particular the VACUUM command will change rowids for tables that do not declare an INTEGER PRIMARY KEY. Therefore, applications should not normally access the rowid directly, but instead use an INTEGER PRIMARY KEY.
\u603b\u7ed3\u8d77\u6765\uff1a\u4e0d\u5e94\u8be5\u76f4\u63a5\u4f7f\u7528 rowid

\u81ea\u5df1\u5e73\u65f6\u5728\u64cd\u4f5c sqlite select row \u7684\u65f6\u5019\uff0c\u4e00\u76f4\u90fd\u662f\u76f4\u63a5\u7528 rowid \u6765\u9009\u53d6\u6267\u884c\u7684\uff0c\u4e00\u5f00\u59cb\u662f\u4e0d\u77e5\u9053 declare primary key as alias of rowid \uff0c\u540e\u6765\u662f\u53d1\u73b0\u6ca1\u6709\u4f7f\u7528\u573a\u666f\u7528\u5230\u3002\u5b98\u7f51\u8ba9\u4e0d\u8981 direct access \u7684\u539f\u56e0\u662f rowid \u6709\u65f6\u5019\u4f1a\u53d8\uff0c\u6bd4\u5982 VACUUM \u3002\u6211\u6ca1\u6709\u7406\u89e3\u8fd9\u53e5\uff0c\u6211\u5c31\u662f\u9700\u8981 rowid \u91cd\u65b0 rebuild \uff0c\u624d\u4f1a\u53bb\u7528 VACUUM \u7684\u554a\uff0c\u5426\u5219\u5f53\u9891\u7e41\u64cd\u4f5c\u6dfb\u52a0\uff0c\u5220\u9664\u52a8\u4f5c\u540e\uff0c\u4e0d\u8fdb\u884c rebuild \uff0c\u6211\u518d\u7528\u8bed\u53e5\u64cd\u4f5c rowid \uff0c\u53ef\u80fd\u5c31\u4e0d\u662f\u6211\u771f\u6b63\u9700\u8981\u64cd\u4f5c\u7684\u884c\u3002\u6240\u4ee5\u6211\u624d\u6bcf\u6b21\u5728\u8fd9\u4e9b\u52a8\u4f5c\u540e\uff0c\u90fd\u4f1a\u8fdb\u884c VACUUM \u3002\u4e3b\u8981\u662f\u4e3a\u4e86\u903b\u8f91\u4e0d\u51fa\u9519\uff0c\u540c\u65f6\u4e4b\u540e\u8bfb\u53d6\u6027\u80fd\u597d\uff0c\u7a7a\u95f4\u5c0f\u3002

\u4f46\u6709\u65f6\u5019 VACUUM \u7684\u65f6\u95f4\u4f1a\u5f88\u957f\uff0c\u53ef\u662f\u4e0d\u64cd\u4f5c\uff0c\u6b64 rowid(true primary key \uff09\u4e0d\u662f\u5f7c rowid \u554a\uff0c\u4f8b\u5982\u5220\u9664\u4e86\u7b2c 6 \u884c\uff0c\u5982\u679c\u4e0d VACUUM, \u6211\u60f3\u518d\u64cd\u4f5c\u65b0\u7684\u7b2c 6 \u884c\uff0c\u8fd9\u4e2a\u65f6\u5019 rowid \u5176\u5b9e\u662f 7 \uff0c\u4e0d\u662f 6 \uff0c\u5c31\u4ea7\u751f\u4e86\u903b\u8f91\u95ee\u9898\u554a\u3002

\u9610\u8ff0\u5f97\u7565\u6df7\u4e71\uff0c\u8bf7\u89c1\u8c05\uff01" }, { "author": { "url": "member/phony2r", "name": "phony2r", "avatar": "https://cdn.v2ex.com/avatar/4eb4/99d2/535530_large.png?m=1657363778" }, "url": "t/850369", "title": "macOS \u4e0a\u6709\u4ec0\u4e48\u597d\u7528\u7684 SQLite GUI ?", "id": "t/850369", "date_published": "2022-05-01T07:29:50+00:00", "content_html": "

\u8bd5\u4e86\u4e00\u4e0b sqlitestudio \u548c db-browser, \u90fd\u4e0d\u597d\u7528\u800c\u4e14\u754c\u9762\u4e5f\u5f88\u4e11

\n" }, { "author": { "url": "member/chenliang0571", "name": "chenliang0571", "avatar": "https://cdn.v2ex.com/avatar/a472/370c/28502_large.png?m=1736635938" }, "url": "t/845542", "title": "SQLite In-Memory \u4f5c\u4e3a\u6570\u636e\u7f13\u5b58\u4ee3\u66ff Java Object", "id": "t/845542", "date_published": "2022-04-07T10:43:11+00:00", "content_html": "

\u80cc\u666f

\n

RESTful API \u9700\u8981\u4ece\u6570\u636e\u5e93\u8bfb\u53d6\u5f88\u591a\u57fa\u7840\u6570\u636e\uff0c\u8fd9\u4e9b\u6570\u636e\u6539\u52a8\u5f88\u5c11\uff0c\u6240\u4ee5\u52a0\u4e86\u4e00\u4e2a\u7f13\u5b58 x \u5206\u949f\u5237\u65b0\u4e00\u6b21\u3002\n\u76ee\u524d\u662f\u76f4\u63a5\u4fdd\u5b58\u5230 Java Object \u7684\u3002

\n

\u95ee\u9898

\n

API \u5404\u7c7b\u8bf7\u6c42\u90fd\u6709\u3002\u57fa\u7840\u6570\u636e\u65b9\u9762\u4e00\u822c\u90fd\u8981\u505a\u4e00\u4e9b\u6570\u636e\u5904\u7406\u7136\u540e\u518d\u7ec4\u5408\u5176\u4ed6\u6570\u636e\u8fd4\u56de\u3002\u7b80\u5355\u7684\u6bd4\u5982 sort \uff0c\u590d\u6742\u7684\u8981\u5148 group by \u7136\u540e\u5728\u7b5b\u9009\u7b49\u3002\n\u4f7f\u7528 Java Stream API \u80fd\u505a\uff0c\u4f46\u662f\u611f\u89c9\u6709\u70b9\u9ebb\u70e6\uff0c\u4e0d\u5982 SQL \u65b9\u4fbf\u3002

\n
\n

\u6240\u4ee5\u60f3\u5230\u4e86 SQLite In-Memory \uff0c\u5982\u679c\u628a\u6570\u636e\u4fdd\u5b58\u5728 SQLite \u5185\uff0c\u90a3\u4e48\u67e5\u8be2\u4f1a\u76f4\u89c2\u5f88\u591a\uff0c\u800c\u4e14\u611f\u89c9\u4f5c\u4e3a In-Memory \u7684\u6570\u636e\u5e93\uff0c\u901f\u5ea6\u5dee\u5f02\u5e94\u8be5\u4e0d\u5927\uff1f

\n

\u4e0d\u77e5\u9053\u6709\u6ca1\u6709 v \u53cb\u6709\u76f8\u5173\u7ecf\u9a8c\u53ef\u4ee5\u5206\u4eab\u7684\u3002

\n" }, { "author": { "url": "member/EyebrowsWhite", "name": "EyebrowsWhite", "avatar": "https://cdn.v2ex.com/avatar/530c/66b8/511263_large.png?m=1754383340" }, "url": "t/841132", "title": "\u4ec0\u4e48\u65f6\u5019\u8c03\u7528 sqlite.close()\u5462", "id": "t/841132", "date_published": "2022-03-17T14:57:08+00:00", "content_html": "

\u5728 stack overflow \u4e0a\u641c\u4e86\u4e00\u4e0b\uff0c\u56de\u7b54\u6bd4\u8f83\u5c11\uff0c\u800c\u4e14\u770b\u7684\u4e0d\u662f\u5f88\u61c2\uff0c\u7279\u6765\u95ee\u95ee\u8bf8\u4f4d\u3002

\n

\u524d\u63d0\uff1a\u53ea\u6709\u4e00\u4e2a\u6570\u636e\u5e93

\n

\u4e3b\u8981\u8003\u8651\u4ee5\u4e0b\u51e0\u79cd\u573a\u666f:

\n
    \n
  1. \u521b\u5efa\u4e00\u4e2a\u6216\u591a\u4e2a\u65b0\u8868
  2. \n
  3. \u589e\u3001\u5220\u3001\u6539 \u6570\u636e\uff08\u4f7f\u7528\u4e8b\u52a1\uff09
  4. \n
  5. \u67e5 \u6570\u636e
  6. \n
\n

\u5982\u679c\u4f7f\u7528 Serialized Mode \uff0c\u90a3\u4e48\u662f\u4e0d\u662f\u65e0\u8bba\u4ec0\u4e48\u65f6\u5019\u90fd\u6ca1\u5fc5\u8981\u53bb\u8c03\u7528 close \u65b9\u6cd5\uff0c\u7b49\u7740\u5783\u573e\u56de\u6536\u5c31\u662f\uff1f

\n

\u5982\u679c\u4f7f\u7528 Multi-thread/Single-thread Mode \uff0c\u90a3\u4e48\u662f\u4e0d\u662f\u9700\u8981\u5728\u524d\u4e24\u79cd\u573a\u666f\u4e0b\u624b\u52a8\u8c03\u7528 close \u5462\uff1f

\n" }, { "author": { "url": "member/shellc", "name": "shellc", "avatar": "https://cdn.v2ex.com/avatar/55ae/2484/26509_large.png?m=1646793034" }, "url": "t/837714", "title": "\u56de\u590d\u201c\u4ec0\u4e48\u573a\u666f\u4e0b\u7528 SQLite\u201d\u7684\u4e3b\u9898\u5e76\u5206\u4eab\u4e00\u4e2a\u5e74\u6536\u5165 60 \u4e07\u5200\u7684\u6280\u672f\u6808", "id": "t/837714", "date_published": "2022-03-03T07:43:06+00:00", "content_html": "

\u8fd9\u4f4d\u5144\u5f1f\u5728\u95ee\u201c\u5927\u5bb6\u6709\u7528 Sqlite \u7684\u5417\uff0c\u90fd\u662f\u4ec0\u4e48\u573a\u666f\u4e0b\u8981\u7528\u8fd9\u4e2a\uff0c\u80fd\u8bf4\u4e00\u4e24\u70b9\u975e\u8981\u7528\u5b83\u7684\u7406\u7531\u6700\u597d\u5566\u201d

\n

\u6211\u89c9\u5f97\u6709\u5fc5\u8981\u5206\u4eab\u4e00\u4e2a\u4eba\u7684\u6545\u4e8b(How Pieter Levels learned to code)\uff0c\u8fd9\u4e2a\u53eb Pieter Levels \u7684\u54e5\u4eec\u81ea\u5b66\u7f16\u7a0b\u5199\u4e86\u4e24\u4e2a\u7f51\u7ad9\uff0c\u76ee\u524d\u5df2\u7ecf\u505a\u5230\u6bcf\u5e74\u6536\u5165 60 \u4e07\u5200\u3002\u770b\u770b\u4ed6\u7684\u6280\u672f\u6808\uff1a

\n\n

\u6211\u4e4b\u524d\u63a5\u89e6\u8fc7\u5f88\u591a\u72ec\u7acb\u5f00\u53d1\u8005\u548c\u5c0f\u56e2\u961f\uff0c\u5f88\u591a\u9009\u62e9\u4e86\u975e\u5e38\u91cd\u7684\u67b6\u6784\uff0c\u6bd4\u5982\u5fae\u670d\u52a1\u3001K8S \u3002\u5176\u5b9e\uff0c\u7edd\u5927\u90e8\u5206\u521b\u4e1a\u9879\u76ee\u6700\u540e\u90fd\u6b7b\u6389\u4e86\uff0c\u521b\u4e1a\u56e2\u961f\u628a\u5927\u91cf\u7684\u65f6\u95f4\u6d6a\u8d39\u5728\u4e86\u89e3\u51b3\u6c38\u8fdc\u4e0d\u53ef\u80fd\u53d1\u751f\u7684\u89c4\u6a21\u548c\u590d\u6742\u6027\u95ee\u9898\u4e0a\u3002\u4ed6\u4eec\u81c6\u60f3\u4e86\u4e00\u4e2a\u751c\u871c\u7684\u70e6\u607c\uff0c\u5e76\u82b1\u4e86\u5927\u91cf\u7684\u65f6\u95f4\u548c\u94b1\u6765\u8bd5\u56fe\u89e3\u51b3\u5b83\u3002

\n

\u4e5f\u6709\u4e00\u4e9b\u5f00\u53d1\u8005\u5f88\u52a1\u5b9e\u7684\u9009\u62e9\u4e86 serverless \u3001django \uff0c\u5feb\u901f rush \u51fa\u4e00\u4e2a MVP \uff0c\u53d1\u73b0\u5546\u4e1a\u4e0d\u53ef\u884c\u5c31\u5feb\u901f\u6254\u6389\u3002

\n

\u6211\u591a\u5e74\u524d\u770b\u300a\u9ed1\u5ba2\u4e0e\u753b\u5bb6\u300b\uff0cPaul Graham \u8bf4 Lisp \u548c Python \u624d\u662f\u521b\u4e1a\u516c\u53f8\u8be5\u7528\u7684\u8bed\u8a00\uff0c\u5176\u5b9e\u6211\u5e76\u4e0d\u7406\u89e3\uff0c\u6211\u90a3\u65f6\u5019\u8fd8\u5728 C++\u6027\u80fd\u66f4\u597d\u7684\u8ba4\u77e5\u91cc\u3002\u6700\u8fd1\u4e24\u5e74\u5927\u70ed\u7684 No-Code \u548c Low-Code \uff0c\u6211\u4e5f\u6ca1\u6709\u592a\u6df1\u7684\u4f53\u4f1a\u3002

\n

\u76f4\u5230\u6700\u8fd1\u534a\u5e74\uff0c\u6211\u81ea\u5df1\u7528 Go \u548c Python \u5199\u4e86\u4e24\u4e2a\u5931\u8d25\u7684\u9879\u76ee\uff0c\u6211\u624d\u660e\u767d\u4e86\u3002\u5bf9\u4e8e\u4ee5\u5546\u4e1a\u6210\u529f\u4e3a\u76ee\u6807\u7684\u9879\u76ee\uff0c\u5feb\u901f\u8bd5\u9519\uff0c\u964d\u4f4e\u5199\u4ee3\u7801\u7684\u6210\u672c\u662f\u591a\u4e48\u91cd\u8981\u3002

\n" }, { "author": { "url": "member/papaer", "name": "papaer", "avatar": "https://cdn.v2ex.com/avatar/f110/2c94/538859_large.png?m=1650878542" }, "url": "t/837599", "date_modified": "2022-03-03T07:01:31+00:00", "content_html": "", "date_published": "2022-03-03T01:54:06+00:00", "title": "\u5927\u5bb6\u6709\u7528 Sqlite \u7684\u5417\uff0c\u90fd\u662f\u4ec0\u4e48\u573a\u666f\u4e0b\u8981\u7528\u8fd9\u4e2a\uff0c\u80fd\u8bf4\u4e00\u4e24\u70b9\u975e\u8981\u7528\u5b83\u7684\u7406\u7531\u6700\u597d\u5566", "id": "t/837599" }, { "author": { "url": "member/Livid", "name": "Livid", "avatar": "https://cdn.v2ex.com/avatar/c4ca/4238/1_large.png?m=1776858751" }, "url": "t/835996", "title": "SQLite Viewer Web App", "id": "t/835996", "date_published": "2022-02-23T10:24:38+00:00", "content_html": "\u4e00\u4e2a\u53ef\u4ee5\u5728\u6d4f\u89c8\u5668\u91cc\u4f7f\u7528\u7684 SQLite \u6570\u636e\u5e93\u6d4f\u89c8\u5de5\u5177\u3002

\u4f7f\u7528\u4e86\u6d4f\u89c8\u5668\u7684\u539f\u751f\u6587\u4ef6\u7cfb\u7edf API \u6765\u6253\u5f00 .sqlite \u6587\u4ef6\u3002

\u4e5f\u53ef\u4ee5\u4f5c\u4e3a PWA \u5b89\u88c5\u3002

https://sqliteviewer.app/" }, { "author": { "url": "member/zyxk", "name": "zyxk", "avatar": "https://cdn.v2ex.com/avatar/7b48/1ffc/193416_large.png?m=1764699089" }, "url": "t/797813", "title": "\u672c\u5730\u6570\u636e\u5e93 \u9664\u4e86 SQLite \u8fd8\u6709\u4ec0\u4e48\u597d\u7528\u7684.", "id": "t/797813", "date_published": "2021-08-24T16:02:33+00:00", "content_html": "\u672c\u5730\u6570\u636e\u5e93 \u9664\u4e86 SQLite \u8fd8\u6709\u4ec0\u4e48\u597d\u7528\u7684.\u4e3b\u8981\u662f PC \u8f6f\u4ef6\u7528\u7684,\u8f6f\u4ef6\u8981\u514d\u5b89\u88c5.
\u597d\u50cf\u5c31 SQLite \u6700\u4f18\u89e3\u4e86\u5427,\u6709\u6ca1\u6709\u5176\u4ed6\u7684\u5462," }, { "author": { "url": "member/jk1030", "name": "jk1030", "avatar": "https://cdn.v2ex.com/gravatar/7c52f924084c13fd0212bcef51e75619?s=73&d=retro" }, "url": "t/796202", "title": "\u8bf7\u6559\u4e00\u4e2a\u65b9\u6848\uff0c\u8fb9\u7f18\u8bbe\u5907\u7684 sqlite \u6570\u636e\u5982\u4f55\u624d\u80fd\u83b7\u53d6\u5230", "id": "t/796202", "date_published": "2021-08-17T01:34:03+00:00", "content_html": "rt,
1.\u7531\u4e8e\u7f51\u7edc\u548c\u73af\u5883\u3002\u6ca1\u6709\u529e\u6cd5\u5b9e\u65f6\u5b58\u5230\u6570\u636e\u8282\u70b9\uff0c\u53ea\u80fd\u5b58\u5728\u672c\u5730\u7684 sqlite,
2.\u6570\u636e\u60c5\u51b5\u6bd4\u8f83\u7279\u6b8a\uff0c\u4e0d\u80fd\u4f7f\u7528 mqtt \u534f\u8bae\u7b49

\u76ee\u524d\u60f3\u5230\u7684\u662f\u662f\u4e0d\u662f\u53ea\u80fd\u5728\u8bbe\u5907\u4e0a\u641e\u4e00\u4e2a sqlite \u7684\u4ee3\u7406\u670d\u52a1\u4e86" }, { "author": { "url": "member/lxk11153", "name": "lxk11153", "avatar": "https://cdn.v2ex.com/avatar/f5da/d6c5/447378_large.png?m=1571323366" }, "url": "t/696413", "date_modified": "2020-08-07T03:58:21+00:00", "content_html": "\n", "date_published": "2020-08-07T03:53:35+00:00", "title": "\u6709\u4eba\u77e5\u9053\u600e\u4e48\u5728 termux \u4e0a\u7f16\u8bd1 sqlcipher \u5417\uff1f", "id": "t/696413" }, { "author": { "url": "member/Iamnotfish", "name": "Iamnotfish", "avatar": "https://cdn.v2ex.com/avatar/455e/aa24/382296_large.png?m=1553022519" }, "url": "t/588683", "date_modified": "2019-08-02T17:54:10+00:00", "content_html": "

| Department | Sub-department | Category | Unit |
\n| ---------- | -------------- | -------- | -------- |
\n| Id | Id | Id | Id |
\n| Name | Name | Name | Name |
\n| Position | Position | Position | Position |
\n| Active | | | |

\n

\u4e00\u5171\u56db\u5f20\u8868\uff0c\u5173\u7cfb\u4ece\u5de6\u81f3\u53f3\u90fd\u662f\u4e00\u5bf9\u591a\u3002\u73b0\u5728\u6211\u95ee\u9898\u662f\u5982\u679c\u6211\u6dfb\u52a0\u5916\u952e\u7528\u6765\u94fe\u8868\u7684\u8bdd\uff0cunit \u8fd9\u5f20\u6700\u5c0f\u7684\u8868\u7684\u6570\u636e\u91cf\u5c06\u4f1a\u975e\u5e38\u5927\u800c\u4e14\u5f88\u591a\u90fd\u662f\u91cd\u590d\u7684\u3002\u56db\u5f20\u8868\u7684\u5177\u4f53\u6570\u636e\u5982\u4e0b\uff1a
\nDepartment\n| Id | Name(STR) | Position(INT) | Active(INT) |
\n| ---- | --------- | ------------- | ----------- |
\n| 1 | AAA | 1 | 0 |
\n| 2 | BBB | 2 | 0 |
\n| 3 | CCC | 3 | 1 |
\n| 4 | DDD | 4 | 1 |

\n

Sub-department
\n| Id | Name(STR) | Position(INT) |
\n| ---- | --------- | ------------- |
\n| 1 | AAA | 1 |
\n| 2 | BBB | 2 |
\n| 3 | CCC | 3 |
\n| 4 | DDD | 4 |

\n

Category
\n| Id | Name(STR) | Position(INT) |
\n| ---- | --------- | ------------- |
\n| 1 | AAA | 1 |
\n| 2 | BBB | 2 |
\n| 3 | CCC | 3 |
\n| 4 | DDD | 4 |

\n

Unit
\n| Id | Name(STR) | Position(INT) |
\n| ---- | --------- | ------------- |
\n| 1 | AAA | 1 |
\n| 2 | BBB | 2 |
\n| 3 | CCC | 3 |
\n| 4 | DDD | 4 |

\n

\u8bf7\u95ee\u4e00\u4e0b\u6211\u8be5\u600e\u4e48\u4fee\u6539\u6211\u7684\u8868\u7684\u7ed3\u6784\u907f\u514d\u91cd\u590d\u6570\u636e\u4ea7\u751f\u5462\uff1f

\n

\u8865\u5145\u4e00\u4e0b\uff01\u5177\u4f53\u7684\u4e1a\u52a1\u662f\u7c7b\u4f3c\u4e8e\u8def\u5f84\u67e5\u627e\u90a3\u6837\u7684\uff0c\u70b9\u5f00\u6211\u7684\u7535\u8111\u7136\u540e\u663e\u51fa\u51fa\u6765\u6240\u6709\u7684\u5728\u6211\u7684\u7535\u8111\u4e0b\u7684\u6587\u4ef6\u5939\uff0c\u7136\u540e\u9009\u62e9\u4e0d\u540c\u7684\u6587\u4ef6\u5939\u8fdb\u5165\u91cc\u9762\u5728\u8fdb\u5165\u5230\u5b50\u6587\u4ef6\u5939\u8fd9\u6837\u3002

\n", "date_published": "2019-08-02T17:49:09+00:00", "title": "\u6c42\u4e00\u4e2a\u6570\u636e\u5e93\u8bbe\u8ba1\u95ee\u9898\uff01", "id": "t/588683" }, { "author": { "url": "member/hxt", "name": "hxt", "avatar": "https://cdn.v2ex.com/avatar/7113/6483/326759_large.png?m=1583290816" }, "url": "t/531196", "title": "SQLite \u88ab\u66dd\u6f0f\u6d1e,\u5f71\u54cd\u8303\u56f4\u5f88\u5927", "id": "t/531196", "date_published": "2019-01-28T04:23:45+00:00", "content_html": "\u524d\u6bb5\u65e5\u5b50\uff0c\u817e\u8baf\u5b89\u5168\u5e73\u53f0\u53d1\u73b0\uff0cSQLite \u5b58\u5728\u4e00\u7ec4\u540d\u4e3a\"\u9ea6\u54f2\u4f26\"\u7684\u6f0f\u6d1e\uff0c\u5229\u7528\u8fd9\u7ec4\u6f0f\u6d1e\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u5728\u7528\u6237\u8bbe\u5907\u4e0a\u8fdc\u7a0b\u8fd0\u884c\u6076\u610f\u4ee3\u7801\uff0c\u5bfc\u81f4\u7528\u6237\u9690\u79c1\u6570\u636e\u6cc4\u6f0f\u6216\u8bbe\u5907\u88ab\u63a7\u5236\u3002

SQLite \u662f\u4e00\u6b3e\u57fa\u4e8e\u78c1\u76d8\u7684\u5173\u7cfb\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff0c\u51e0\u4e4e\u53ef\u4e0e\u6240\u6709\u8bbe\u5907\u3001\u5e73\u53f0\u548c\u7f16\u7a0b\u8bed\u8a00\u517c\u5bb9\u3002\u622a\u81f3\u76ee\u524d\uff0c\u5df2\u6709\u6570\u767e\u4e07\u5e94\u7528\u7a0b\u5e8f\u4f7f\u7528 SQLite \u5b8c\u6210\u4e86\u6570\u5341\u4ebf\u6b21\u5b89\u88c5\uff0c\u4f17\u591a\u7269\u8054\u7f51\u8bbe\u5907\u3001Windows \u5e94\u7528\u7a0b\u5e8f\u3001mac OS \u53ca Web \u6d4f\u89c8\u5668\u6613\u53d7\u5f71\u54cd\u3002\u6bd4\u8f83\u5178\u578b\u7684\u662f\u57fa\u4e8e Chromium \u7684\u6d4f\u89c8\u5668\uff0c\u5305\u62ec Google Chrome\u3001Vivaldi\u3001Opera \u548c Brave \u7b49\u4e3b\u6d41\u6d4f\u89c8\u5668\u53d7\u5230\u5f71\u54cd\u3002

\u5982\u679c\u7528\u6237\u4f7f\u7528\u4e86\u6ca1\u6709\u4fee\u590d\u6f0f\u6d1e\u7684\u6d4f\u89c8\u5668\u6216\u8005 APP\uff0c\u4e00\u4e2a\u5f88\u5e38\u89c1\u7684\u573a\u666f\u5c31\u662f\uff0c\u6253\u5f00\u653b\u51fb\u8005\u7684\u7f51\u7ad9(\u6216\u8005\u626b\u63cf\u4e8c\u7ef4\u7801)\uff0c\u653b\u51fb\u8005\u5c31\u53ef\u4ee5\u8fdc\u7a0b\u5728\u7528\u6237\u7684\u6d4f\u89c8\u5668\u6216\u8005 APP \u91cc\u6267\u884c\u4efb\u610f\u547d\u4ee4\u3002

https://blade.tencent.com/magellan/index.html" }, { "author": { "url": "member/dalieba", "name": "dalieba", "avatar": "https://cdn.v2ex.com/avatar/3364/fcbb/301234_large.png?m=1542988025" }, "url": "t/497522", "title": "\u4e24\u4e2a\u8bfb\u5199 SQLite \u6570\u636e\u5e93\u7684\u6d4f\u89c8\u5668\u6269\u5c55", "id": "t/497522", "date_published": "2018-10-14T08:16:01+00:00", "content_html": "\u6709\u4e24\u5bb6\u7f51\u7ad9\u53d1\u5e03\u4e86\u53ef\u4ee5\u8ba9\u6d4f\u89c8\u5668\u7f16\u8f91 SQLite \u7684\u6269\u5c55\uff0c\u53ea\u9700\u4e00\u4e2a sql.js \u5c31\u80fd\u8dd1\u8d77\u6765\u4e00\u4e2a\u6570\u636e\u5e93\u3002
http://add0n.com/sqlite-manager.html
http://mybrowseraddon.com/sql-reader.html" }, { "author": { "url": "member/Livid", "name": "Livid", "avatar": "https://cdn.v2ex.com/avatar/c4ca/4238/1_large.png?m=1776858751" }, "url": "t/52719", "title": "How SQLite is tested", "id": "t/52719", "date_published": "2012-11-18T13:16:39+00:00", "content_html": "http://sqlite.org/testing.html" }, { "author": { "url": "member/013231", "name": "013231", "avatar": "https://cdn.v2ex.com/gravatar/3d91a083d47c66019bcda1f3a9b32fde?s=73&d=retro" }, "url": "t/40127", "title": "\u5982\u679c\u9700\u8981\u5beb\u5165\u6578\u64da, \u4e0d\u50c5\u6578\u64da\u6587\u4ef6\u8981\u6709\u5beb\u5165\u6b0a\u9650, \u6578\u64da\u6587\u4ef6\u6240\u5728\u7684\u76ee\u9304\u4e5f\u8981\u6709\u5beb\u5165\u6b0a\u9650", "id": "t/40127", "date_published": "2012-06-20T17:15:25+00:00", "content_html": "\"When a process wants to change a database file (and it is not in WAL mode), it first records the original unchanged database content in a rollback journal. The rollback journal is an ordinary disk file that is always located in the same directory or folder as the database file and has the same name as the database file with the addition of a -journal suffix. The rollback journal also records the initial size of the database so that if the database file grows it can be truncated back to its original size on a rollback.\"
\u6240\u4ee5\u5462, \u5982\u679c\u6578\u64da\u6587\u4ef6\u6240\u5728\u7684\u76ee\u9304\u6c92\u7528\u5beb\u6b0a\u9650, journal\u6587\u4ef6\u7121\u6cd5\u5275\u5efa, \u5c31\u7121\u6cd5\u5beb\u5165\u6578\u64da\u4e86.

\u5728Python sqlite3 Package\u4e2d, \u6703\u62cb\u51fa\u4e00\u500b\u9817\u6709\u8aa4\u5c0e\u6027\u7684Error:
OperationalError: unable to open database file
\u7136\u800c\u771f\u6b63\u7684\u932f\u8aa4\u539f\u56e0\u4e26\u4e0d\u662f\u7121\u6cd5\u6253\u958b\u6578\u64da\u6587\u4ef6, \u800c\u662f\u7121\u6cd5\u5275\u5efa\u65e5\u8a8c\u6587\u4ef6.
\u88ab\u9019\u500b\u554f\u984c\u6298\u9a30\u4e86\u534a\u5929..." }, { "author": { "url": "member/yetone", "name": "yetone", "avatar": "https://cdn.v2ex.com/avatar/d440/03cb/13218_large.png?m=1752160683" }, "url": "t/39535", "date_modified": "2012-06-14T17:26:53+00:00", "content_html": "\u4f1a\u4e0d\u4f1a\u627f\u53d7\u4e0d\u4e86\u5f88\u5927\u7684\u8bf7\u6c42\u554a\uff0c\u6b63\u5728\u8003\u8651\u8981\u4e0d\u8981\u8f6c\u6210mysql\uff0csqlite3\u548cmysql\u7684\u8bed\u6cd5\u76f8\u5dee\u5927\u4e0d\u5927\uff1f", "date_published": "2012-06-14T15:47:59+00:00", "title": "\u7528sqlite3\u4f5c\u4e3a\u8bba\u575b\u7684\u6570\u636e\u5e93\u884c\u4e0d\u884c\uff1f", "id": "t/39535" }, { "author": { "url": "member/jyoe", "name": "jyoe", "avatar": "https://cdn.v2ex.com/avatar/359f/3846/1390_large.png?m=1589356623" }, "url": "t/33481", "date_modified": "2012-04-25T02:48:39+00:00", "content_html": "About Sqlite
1001 wget http://www.sqlite.org/sqlite-autoconf-3071100.tar.gz
1002 tar zxvf sqlite-autoconf-3071100.tar.gz
1003 cd sqlite-autoconf-3071100
1008 ./configure
1009 make
1010 make install

sqlite3 test // \u6ca1\u6709\u5c31\u521b\u5efa\u8fd9\u4e2adb \u6709\u4e86\u5c31\u8fdb\u5165\u8be5db \u6211\u9760 \u597d\u7075\u5de7
\u6728\u6709show tables; \u4f46\u53ef\u4ee5\u7528.tables or .table
\u6728\u6709show databases; \u4f46\u6709.databases;
sqlite> .schema
CREATE TABLE user(id integer primary key,username text ,country text);
CREATE TABLE user_card(id integer primary key,username text ,country text);
sqlite> .schema user
CREATE TABLE user(id integer primary key,username text ,country text);

\u8fd9\u8ba9show create table xxx \u60c5\u4f55\u4ee5\u582a...


order by \u5565\u7684\u8fd8\u90fd\u6b63\u5e38

DataType\u53ef\u601c \u4f46\u7cbe\u5de7\u591f\u7528
NULL
INTEGER
REAL
TEXT
BLOB
\u4f46\u8c8c\u4f3c\u4e5f\u652f\u6301date time\u5565\u7684\u8fd9\u4e9b\u5e38\u89c4Type


About Create Index
CREATE [UNIQUE] INDEX index-name
ON [database-name .] table-name (column-name [, column-name]*)
[ON CONFLICT conflict-algorithm]

Query:
SELECT [ALL | DISTINCT] result [FROM table-list]
[WHERE expr]
[GROUP BY expr-list]
[HAVING expr]
[compound-op select]*
[ORDER BY sort-expr-list]
[LIMIT integer [(OFFSET|,) integer]]

sqlite3\u4e5f\u63a5\u53d7\u5982\u4e0b\u7684\u6570\u636e\u7c7b\u578b\uff1a
smallint 16 \u4f4d\u5143\u7684\u6574\u6570\u3002
interger 32 \u4f4d\u5143\u7684\u6574\u6570\u3002
decimal(p,s) p \u7cbe\u786e\u503c\u548c s \u5927\u5c0f\u7684\u5341\u8fdb\u4f4d\u6574\u6570\uff0c\u7cbe\u786e\u503cp\u662f\u6307\u5168\u90e8\u6709\u51e0\u4e2a\u6570(digits)\u5927\u5c0f\u503c\uff0cs\u662f\u6307\u5c0f\u6570\u70b9\u5f8c\u6709\u51e0\u4f4d\u6570\u3002\u5982\u679c\u6ca1\u6709\u7279\u522b\u6307\u5b9a\uff0c\u5219\u7cfb\u7edf\u4f1a\u8bbe\u4e3a p=5; s=0 \u3002
float 32\u4f4d\u5143\u7684\u5b9e\u6570\u3002
double 64\u4f4d\u5143\u7684\u5b9e\u6570\u3002
char(n) n \u957f\u5ea6\u7684\u5b57\u4e32\uff0cn\u4e0d\u80fd\u8d85\u8fc7 254\u3002
varchar(n) \u957f\u5ea6\u4e0d\u56fa\u5b9a\u4e14\u5176\u6700\u5927\u957f\u5ea6\u4e3a n \u7684\u5b57\u4e32\uff0cn\u4e0d\u80fd\u8d85\u8fc7 4000\u3002
graphic(n) \u548c char(n) \u4e00\u6837\uff0c\u4e0d\u8fc7\u5176\u5355\u4f4d\u662f\u4e24\u4e2a\u5b57\u5143 double-bytes\uff0c n\u4e0d\u80fd\u8d85\u8fc7127\u3002\u8fd9\u4e2a\u5f62\u6001\u662f\u4e3a\u4e86\u652f\u63f4\u4e24\u4e2a\u5b57\u5143\u957f\u5ea6\u7684\u5b57\u4f53\uff0c\u4f8b\u5982\u4e2d\u6587\u5b57\u3002
vargraphic(n) \u53ef\u53d8\u957f\u5ea6\u4e14\u5176\u6700\u5927\u957f\u5ea6\u4e3a n \u7684\u53cc\u5b57\u5143\u5b57\u4e32\uff0cn\u4e0d\u80fd\u8d85\u8fc7 2000
date \u5305\u542b\u4e86 \u5e74\u4efd\u3001\u6708\u4efd\u3001\u65e5\u671f\u3002
time \u5305\u542b\u4e86 \u5c0f\u65f6\u3001\u5206\u949f\u3001\u79d2\u3002
timestamp \u5305\u542b\u4e86 \u5e74\u3001\u6708\u3001\u65e5\u3001\u65f6\u3001\u5206\u3001\u79d2\u3001\u5343\u5206\u4e4b\u4e00\u79d2\u3002

Sqlite Datetime
sqlite> SELECT strftime('%Y/%m/%d', '2004-10-31');
2004/10/31
sqlite> SELECT strftime('%Y/%m/%d', datetime());
2012/04/05

sqlite> SELECT strftime('%Y-%m-%d %H:%M:%S', datetime());
2012-04-05 03:02:57

sqlite> SELECT strftime('%Y-%m-%d %H:%M:%S day of the week:%w Week of year:%W', datetime());
2012-04-05 03:04:52 day of the week:4 Week of year:14

// %w Day of week, 0-6 (0 is Sunday)


SELECT strftime('%H:%M:%S',time(), '+1 hours'); // \u4e00\u4e2a\u5c0f\u65f6\u4e4b\u540e
SELECT strftime('%Y-%m-%d %H:%M:%S',datetime(),'+1 years'); //\u4e00\u5e74\u4e4b\u540e
SELECT strftime('%Y-%m-%d %H:%M:%S',datetime(),'+1 hours','+1 years'); // \u4e00\u5e74\u4e4b\u540e\u7684\u8fd9\u4e00\u5929\u7684\u4e00\u5c0f\u65f6\u4ee5\u540e
SELECT datetime('now', 'start of month'); // 2012-04-01 00:00:00 \u8fd9\u4e2a\u6708\u7684\u7b2c\u4e00\u5929 month\u53ef\u4ee5\u6539\u6210\u5e74
SELECT time('12:00', 'localtime');
SELECT time('12:00', 'utc');", "date_published": "2012-04-25T02:47:50+00:00", "title": "About Sqlite \u4e4b\u524d\u7684\u4e00\u7bc7\u7b14\u8bb0", "id": "t/33481" }, { "author": { "url": "member/hermitu", "name": "hermitu", "avatar": "https://cdn.v2ex.com/avatar/92a0/8bf9/3141_large.png?m=1331654102" }, "url": "t/25395", "date_modified": "2012-04-21T16:53:13+00:00", "content_html": "\u7528sqlfairy\u8f6c\u6362sqlite\u5230mysql\uff0c\u4f46\u662f\u8f6c\u6362\u4e2d\u9014\u663e\u793aout of memory. \u6211\u60f3\u662fsqlite\u6587\u4ef6\u592a\u5927\u4e86\u5427\uff0c\u5982\u679c\u5206\u5272\u6210\u5c0f\u7684\uff0c\u4f30\u8ba1\u5c31\u89e3\u51b3\u95ee\u9898\u4e86\u3002\u3002\u3002\u4f46\u662f\u6ca1\u627e\u5230\u5206\u5272\u5de5\u5177\u3002", "date_published": "2012-01-11T07:48:50+00:00", "title": "\u5982\u4f55\u628a\u4e00\u4e2a2G\u7684sqlite\u6570\u636e\u5e93\u5206\u5272\u6210\u5c0f\u7684\uff1f", "id": "t/25395" }, { "author": { "url": "member/Livid", "name": "Livid", "avatar": "https://cdn.v2ex.com/avatar/c4ca/4238/1_large.png?m=1776858751" }, "url": "t/12281", "date_modified": "2012-04-21T14:23:01+00:00", "content_html": "http://menial.co.uk/2011/02/18/base-2-0/\r\n
\r\n
The best SQLite manager for Mac OS X.", "date_published": "2011-04-28T10:41:23+00:00", "title": "Base 2.0", "id": "t/12281" } ] } ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86