{"id":135854,"date":"2019-02-11T14:03:09","date_gmt":"2019-02-11T06:03:09","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=135854"},"modified":"2019-02-12T13:04:24","modified_gmt":"2019-02-12T05:04:24","slug":"sqlite-3271","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/sqlite-3271.html","title":{"rendered":"\u672c\u5730SQL\u6570\u636e\u5e93\u670d\u52a1\u8f6f\u4ef6\uff1aSQLite \u53d1\u5e033.27.1\u5566"},"content":{"rendered":"

SQLite\u662f\u9075\u5b88ACID\u7684\u5173\u8054\u5f0f\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff0c\u5b83\u5305\u542b\u5728\u4e00\u4e2a\u76f8\u5bf9\u5c0f\u7684C\u5e93\u4e2d\u3002\u5b83\u662fD.RichardHipp\u5efa\u7acb\u7684\u516c\u6709\u9886\u57df\u9879\u76ee\u3002<\/p>\n

\u4e0d\u50cf\u5e38\u89c1\u7684\u5ba2\u6237-\u670d\u52a1\u5668\u8303\u4f8b\uff0cSQLite\u5f15\u64ce\u4e0d\u662f\u4e2a\u7a0b\u5e8f\u4e0e\u4e4b\u901a\u4fe1\u7684\u72ec\u7acb\u8fdb\u7a0b\uff0c\u800c\u662f\u8fde\u63a5\u5230\u7a0b\u5e8f\u4e2d\u6210\u4e3a\u5b83\u7684\u4e00\u4e2a\u4e3b\u8981\u90e8\u5206\u3002\u6240\u4ee5\u4e3b\u8981\u7684\u901a\u4fe1\u534f\u8bae\u662f\u5728\u7f16\u7a0b\u8bed\u8a00\u5185\u7684\u76f4\u63a5API\u8c03\u7528\u3002\u8fd9\u5728\u6d88\u8017\u603b\u91cf\u3001\u5ef6\u8fdf\u65f6\u95f4\u548c\u6574\u4f53\u7b80\u5355\u6027\u4e0a\u6709\u79ef\u6781\u7684\u4f5c\u7528\u3002\u6574\u4e2a\u6570\u636e\u5e93(\u5b9a\u4e49\u3001\u8868\u3001\u7d22\u5f15\u548c\u6570\u636e\u672c\u8eab)\u90fd\u5728\u5bbf\u4e3b\u4e3b\u673a\u4e0a\u5b58\u50a8\u5728\u4e00\u4e2a\u5355\u4e00\u7684\u6587\u4ef6\u4e2d\u3002\u5b83\u7684\u7b80\u5355\u7684\u8bbe\u8ba1\u662f\u901a\u8fc7\u5728\u5f00\u59cb\u4e00\u4e2a\u4e8b\u52a1\u7684\u65f6\u5019\u9501\u5b9a\u6574\u4e2a\u6570\u636e\u6587\u4ef6\u800c\u5b8c\u6210\u7684\u3002<\/p>\n

\"\"<\/p>\n

\u4eceSQLite 3.27.0\u7ee7\u7eed\u8fdb\u884c\u7684\u66f4\u6539\uff1a<\/p>\n

    \n
  1. \u6dfb\u52a0\u4e86VACUUM INTO\u547d\u4ee4<\/li>\n
  2. \u5982\u679c\u4f7f\u7528\u53cc\u5f15\u53f7\u5b57\u7b26\u4e32\u6587\u5b57\uff0c\u5219\u5728\u9519\u8bef\u65e5\u5fd7\u4e0a\u53d1\u51faSQLITE_WARNING\u6d88\u606f\u3002<\/li>\n
  3. sqlite3_normalized_sql()\u63a5\u53e3\u9002\u7528\u4e8e\u4f7f\u7528sqlite3_prepare_v2()\u6216sqlite3_prepare_v3()\u521b\u5efa\u7684\u4efb\u4f55\u9884\u51c6\u5907\u8bed\u53e5\u3002\u4e3a\u4e86\u4f7f\u7528sqlite3_normalized_sql()\uff0c\u4e0d\u518d\u9700\u8981\u5c06sqlite3_prepare_v3()\u4e0eSQLITE_PREPARE_NORMALIZE\u4e00\u8d77\u4f7f\u7528\u3002<\/li>\n
  4. \u5728FTS3\u548cFTS5\u4e2d\u6dfb\u52a0\u4e86remove_diacritics=2\u9009\u9879\u3002<\/li>\n
  5. \u4e3asqlite3_prepare_v3()\u6dfb\u52a0\u4e86SQLITE_PREPARE_NO_VTAB\u9009\u9879\u3002\u4f7f\u7528\u8be5\u9009\u9879\u53ef\u9632\u6b62\u5bf9\u5f71\u5b50\u8868\u7684\u5faa\u73af\u5f15\u7528\u5bfc\u81f4\u8d44\u6e90\u6cc4\u6f0f\u3002<\/li>\n
  6. sqlite3_deserialize()<\/li>\n
  7. \u63a5\u53e3\u7684\u589e\u5f3a\u529f\u80fd\uff1a\n
      \n
    1. \u6dfb\u52a0SQLITE_FCNTL_SIZE_LIMIT\u6587\u4ef6\u63a7\u4ef6\uff0c\u7528\u4e8e\u8bbe\u7f6esqlite3_deserialize\u521b\u5efa\u7684\u5185\u5b58\u6570\u636e\u5e93\u5927\u5c0f\u7684\u4e0a\u9650\u3002\u9ed8\u8ba4\u4e0a\u9650\u4e3a1GiB\uff0c\u6216\u8005sqlite3_config\uff08SQLITE_CONFIG_MEMDB_MAXSIZE\uff09\u548c\/\u6216SQLITE_MEMDB_DEFAULT_MAXSIZE\u6307\u5b9a\u7684\u4efb\u4f55\u66ff\u4ee3\u503c\u3002<\/li>\n
    2. \u5c0a\u91cdSQLITE_DESERIALIZE_READONLY\u6807\u5fd7\uff0c\u8be5\u6807\u5fd7\u5148\u524d\u5df2\u5728\u6587\u6863\u4e2d\u63cf\u8ff0\uff0c\u4f46\u4ee5\u524d\u662f\u65e0\u64cd\u4f5c\u7684\u3002<\/li>\n
    3. \u589e\u5f3aTCL\u63a5\u53e3\u7684\u201c\u53cd\u5e8f\u5217\u5316\u201d\u547d\u4ee4\uff0c\u4e3a\u5176\u63d0\u4f9b\u65b0\u7684\u201c--maxsize N\u201d\u548c\u201c--readonly BOOLEAN\u201d\u9009\u9879\u3002<\/li>\n<\/ol>\n<\/li>\n
    4. CLI\u7684\u589e\u5f3a\u529f\u80fd\uff0c\u4e3b\u8981\u7528\u4e8e\u652f\u6301SQLite\u5e93\u672c\u8eab\u7684\u6d4b\u8bd5\u548c\u8c03\u8bd5\uff1a\n
        \n
      1. CLI\u7684\u589e\u5f3a\u529f\u80fd\uff0c\u4e3b\u8981\u7528\u4e8e\u652f\u6301SQLite\u5e93\u672c\u8eab\u7684\u6d4b\u8bd5\u548c\u8c03\u8bd5\uff1a<\/li>\n
      2. \u6dfb\u52a0\u5bf9\u201c.open --hexdb\u201d\u7684\u652f\u6301\u3002\u7528\u4e8e\u751f\u6210\u201chexdb\u201d\u6587\u672c\u7684\u201cdbtotxt\u201d\u5b9e\u7528\u7a0b\u5e8f\u5c06\u6dfb\u52a0\u5230\u6e90\u6811\u4e2d\u3002<\/li>\n
      3. \u5728\u201c.open --deserialize\u201d\u4e0a\u6dfb\u52a0\u5bf9\u201c--maxsize N\u201d\u9009\u9879\u7684\u652f\u6301\u3002<\/li>\n
      4. \u6dfb\u52a0\u201c--memtrace\u201d\u547d\u4ee4\u884c\u9009\u9879\uff0c\u4ee5\u663e\u793a\u6240\u6709\u5185\u5b58\u5206\u914d\u548c\u91ca\u653e\u3002<\/li>\n
      5. \u4f7f\u7528SQLITE_DEBUG\u5728\u6784\u5efa\u4e0a\u6dfb\u52a0\u201c.eqp trace\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u5728\u4e00\u4e2a\u6b65\u9aa4\u4e2d\u542f\u7528\u5e26\u7f29\u8fdb\u7684\u5b57\u8282\u7801\u7a0b\u5e8f\u5217\u8868\u548cPRAGMA vdbe_trace\u3002<\/li>\n
      6. \u6dfb\u52a0\u201c.progress\u201d\u547d\u4ee4\u4ee5\u8bbf\u95eesqlite3_progress_handler\uff08\uff09\u63a5\u53e3\u3002<\/li>\n
      7. \u5c06\u201c--async\u201d\u9009\u9879\u6dfb\u52a0\u5230\u201c.backup\u201d\u547d\u4ee4\u4e2d\u3002<\/li>\n
      8. \u5c06 \"--expanded\", \"--normalized\", \"--plain\", \"--profile\", \"--row\", \"--stmt\", and \"--close\" to the \".trace\"\u6dfb\u52a0\u5230\u201c.trace\u201d\u4e2d\u547d\u4ee4\u3002<\/li>\n<\/ol>\n<\/li>\n
      9. \u589e\u5f3a\u9488\u5bf9\u6076\u610fSQL\u7684\u7a33\u5065\u6027\uff0c\u8be5\u6076\u610fSQL\u9488\u5bf9\u6076\u610f\u7834\u574f\u7684\u6570\u636e\u5e93\u8fd0\u884c\u3002<\/li>\n<\/ol>\n

        Bug\u4fee\u590d\uff1a<\/strong><\/p>\n

        \u4e0d\u8981\u4f7f\u7528\u90e8\u5206\u7d22\u5f15\u5728IN\u8fd0\u7b97\u7b26\u4e0a\u6267\u884c\u8868\u626b\u63cf\u3002<\/p>\n

        \u4fee\u590d\u67e5\u8be2flattener\uff0c\u4f7f\u5176\u9002\u7528\u4e8e\u5305\u542b\u4f7f\u7528\u7a97\u53e3\u51fd\u6570\u7684\u5b50\u67e5\u8be2\u7684\u67e5\u8be2\u3002<\/p>\n

        \u786e\u4fddALTER TABLE\u4fee\u6539\u5d4c\u5165\u5728\u4f5c\u4e3a\u89c6\u56fe\u548c\u89e6\u53d1\u5668\u4e00\u90e8\u5206\u7684WITH\u5b50\u53e5\u4e2d\u7684\u8868\u540d\u548c\u5217\u540d\u3002<\/p>\n

        \u4fee\u590d\u4e00\u4e2a\u89e3\u6790\u5668\u9519\u8bef\uff0c\u8be5\u9519\u8bef\u963b\u6b62\u5728\u8868\u503c\u51fd\u6570\u5468\u56f4\u4f7f\u7528\u62ec\u53f7\u3002<\/p>\n

        \u4fee\u590d\u8868\u8fbe\u5f0f\u7d22\u5f15\u7684OR\u4f18\u5316\u95ee\u9898\u3002<\/p>\n

        \u4fee\u590dLEFT JOIN\u5f3a\u5ea6\u964d\u4f4e\u4f18\u5316\u7684\u95ee\u9898\uff0c\u5176\u4e2d\u7531\u4e8eIS NOT NULL\u8fd0\u7b97\u7b26\u800c\u4e0d\u9002\u5f53\u5730\u5e94\u7528\u4f18\u5316\u3002<\/p>\n

        \u4fee\u590dREPLACE\u547d\u4ee4\uff0c\u4f7f\u5176\u65e0\u6cd5\u518d\u5c06NULL\u503c\u6f5c\u5165NOT NULL\u5217\uff0c\u5373\u4f7fNOT NULL\u5217\u7684\u9ed8\u8ba4\u503c\u4e3aNULL\u4e5f\u662f\u5982\u6b64\u3002<\/p>\n

        \u4fee\u590d\u4f7f\u7528\u76f8\u5173\u5b50\u67e5\u8be2\u4e2d\u4f7f\u7528\u7684\u7a97\u53e3\u51fd\u6570\u7684\u95ee\u9898\u3002<\/p>\n

        \u4fee\u590dALTER TABLE RENAME COLUMN\u547d\u4ee4\uff0c\u4f7f\u5176\u9002\u7528\u4e8e\u5177\u6709\u5197\u4f59UNIQUE\u7ea6\u675f\u7684\u8868\u3002<\/p>\n

        \u4fee\u590d\u4e86\u5728\u63d2\u5165\u4f7f\u7528\u8868\u8fbe\u5f0f\u7d22\u5f15\u7684\u8868\u65f6\u5bfc\u81f4zeroblob\u503c\u88ab\u622a\u65ad\u7684\u9519\u8bef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

        SQLite\u662f\u9075\u5b88ACID\u7684\u5173\u8054\u5f0f\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff0c\u5b83\u5305\u542b\u5728\u4e00\u4e2a\u76f8\u5bf9\u5c0f\u7684C\u5e93\u4e2d\u3002\u5b83\u662fD.RichardHipp\u5efa […]<\/p>\n","protected":false},"author":317,"featured_media":135859,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[21],"tags":[],"class_list":["post-135854","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/135854","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/317"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=135854"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/135854\/revisions"}],"predecessor-version":[{"id":135956,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/135854\/revisions\/135956"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/135859"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=135854"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=135854"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=135854"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}