{"id":115306,"date":"2024-03-07T08:50:20","date_gmt":"2024-03-07T00:50:20","guid":{"rendered":"http:\/\/www.zhushiyao.com\/?p=115306"},"modified":"2024-03-07T10:34:04","modified_gmt":"2024-03-07T02:34:04","slug":"%e5%be%ae%e4%bf%a1%e4%b8%ba%e4%bb%80%e4%b9%88%e4%bd%bf%e7%94%a8-sqlite-%e4%bf%9d%e5%ad%98%e8%81%8a%e5%a4%a9%e8%ae%b0%e5%bd%95%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/www.zhushiyao.com\/?p=115306","title":{"rendered":"SQLite 3.22.0 -3.26.0 2018 \u5e74\u65b0\u589e\u52a0\u7684 SQL \u529f\u80fd"},"content":{"rendered":"<div class=\"wxsyncmain\">\n<section style=\"margin-bottom: 0px; outline: 0px; visibility: visible;\" data-mpa-template=\"t\" data-mpa-powered-by=\"yiban.io\">\n<p style=\"padding-right: 0.5em; padding-left: 0.5em; outline: 0px; visibility: visible;\"><span style=\"background-color: #ffffff; font-family: arial, helvetica, sans-serif; font-size: 16px; letter-spacing: 0.544px; text-align: left;\">SQLite \u662f\u4e00\u4e2a\u88ab\u5927\u5bb6\u4f4e\u4f30\u7684\u6570\u636e\u5e93\uff0c\u4f46\u6709\u4e9b\u4eba\u8ba4\u4e3a\u5b83\u662f\u4e00\u4e2a\u4e0d\u9002\u5408\u751f\u4ea7\u73af\u5883\u4f7f\u7528\u7684\u73a9\u5177\u6570\u636e\u5e93\u3002\u4e8b\u5b9e\u4e0a\uff0cSQLite \u662f\u4e00\u4e2a\u975e\u5e38\u53ef\u9760\u7684\u6570\u636e\u5e93\uff0c\u5b83\u53ef\u4ee5\u5904\u7406 TB \u7ea7\u7684\u6570\u636e\uff0c\u4f46\u5b83\u6ca1\u6709\u7f51\u7edc\u5c42\u3002\u63a5\u4e0b\u6765\uff0c\u672c\u6587\u5c06\u4e0e\u5927\u5bb6\u5171\u540c\u63a2\u8ba8 SQLite \u5728\u8fc7\u53bb\u4e00\u5e74\u4e2d\u6700\u65b0\u7684 SQL \u529f\u80fd\u3002<\/span><\/p>\n<section style=\"outline: 0px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; background-color: #ffffff; visibility: visible;\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\">\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left; visibility: visible;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif; visibility: visible;\">SQLite \u201c\u53ea\u662f\u201d\u4e00\u4e2a\u5e93\uff0c\u5b83\u4e0d\u662f\u4f20\u7edf\u610f\u4e49\u4e0a\u7684\u670d\u52a1\u5668\u3002\u56e0\u6b64\uff0c\u5728\u67d0\u4e9b\u573a\u5408\u4e0b\uff0c\u5b83\u786e\u5b9e\u4e0d\u5408\u9002\u3002\u4f46\u662f\uff0c\u5728\u76f8\u5f53\u591a\u7684\u5176\u4ed6\u573a\u5408\uff0c\u5b83\u5374\u662f\u6700\u5408\u9002\u7684\u9009\u62e9\u3002SQLite \u53f7\u79f0\u662f\u90e8\u7f72\u548c\u4f7f\u7528\u6700\u5e7f\u6cdb\u7684\u6570\u636e\u5e93\u5f15\u64ce\u3002\u6211\u8ba4\u4e3a\u8fd9\u5f88\u6709\u53ef\u80fd\uff0c\u56e0\u4e3a SQLite \u6ca1\u6709\u7248\u6743\u7684\u9650\u5236\u3002\u65e0\u8bba\u4f55\u65f6\uff0c\u53ea\u8981\u5f00\u53d1\u8005\u60f3\u4f7f\u7528 SQL \u5728\u6587\u4ef6\u4e2d\u5b58\u50a8\u7ed3\u6784\u5316\u7684\u6570\u636e\uff0cSQLite \u5e94\u662f\u9996\u9009\u65b9\u6848\u3002<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left; visibility: visible;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif; visibility: visible;\">SQLite \u7684 SQL \u65b9\u8a00\u4e5f\u975e\u5e38\u5f3a\u5927\u3002\u5b83\u6bd4 MySQL \u65e9\u56db\u5e74\u5c31\u5f00\u59cb\u652f\u6301 with \u8bed\u53e5\u3002\u6700\u8fd1\uff0c\u5b83\u8fd8\u5b9e\u73b0\u4e86\u5bf9\u4e8e\u7a97\u53e3\u51fd\u6570\u7684\u652f\u6301\uff0c\u8fd9\u4ec5\u4ec5\u6bd4 MySQL \u665a\u4e94\u4e2a\u6708\u3002<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left; visibility: visible;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif; visibility: visible;\">\u63a5\u4e0b\u6765\uff0c\u672c\u6587\u5c06\u4ecb\u7ecd SQLite \u5728 2018 \u5e74\u65b0\u589e\u52a0\u7684 SQL \u529f\u80fd\uff0c\u4e5f\u5c31\u662f SQLite \u4ece\u7248\u672c 3.22.0 \u5230 3.26.0 \u6240\u65b0\u589e\u52a0\u7684 SQL \u529f\u80fd\u3002<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left; visibility: visible;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif; visibility: visible;\">\u5177\u4f53\u5185\u5bb9\u5305\u62ec\uff1a<\/span><\/p>\n<ol class=\"list-paddingleft-1\" style=\"padding-left: 1.5em; outline: 0px; visibility: visible;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<li style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif; visibility: visible;\">\n<p style=\"margin-top: 8px; margin-bottom: 8px; outline: 0px; text-align: left; visibility: visible;\"><span style=\"outline: 0px; visibility: visible;\">\u5e03\u5c14\u5b57\u9762\u91cf\u548c\u5224\u65ad<\/span><\/p>\n<\/li>\n<li style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif; visibility: visible;\">\n<p style=\"margin-top: 8px; margin-bottom: 8px; outline: 0px; text-align: left; visibility: visible;\"><span style=\"outline: 0px; visibility: visible;\">\u7a97\u53e3\u51fd\u6570<\/span><\/p>\n<\/li>\n<li style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif; visibility: visible;\">\n<p style=\"margin-top: 8px; margin-bottom: 8px; outline: 0px; text-align: left; visibility: visible;\"><span style=\"outline: 0px; visibility: visible;\">Filter\u5b50\u53e5<\/span><\/p>\n<\/li>\n<li style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif; visibility: visible;\">\n<p style=\"margin-top: 8px; margin-bottom: 8px; outline: 0px; text-align: left; visibility: visible;\"><span style=\"outline: 0px; visibility: visible;\">Insert \u2026 on conflict (\u201cUpsert\u201d)<\/span><\/p>\n<\/li>\n<li style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif; visibility: visible;\">\n<p style=\"margin-top: 8px; margin-bottom: 8px; outline: 0px; text-align: left; visibility: visible;\"><span style=\"outline: 0px; visibility: visible;\">\u91cd\u547d\u540d\u5217<\/span><\/p>\n<\/li>\n<li style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\n<p style=\"margin-top: 8px; margin-bottom: 8px; outline: 0px; text-align: left;\"><span style=\"outline: 0px;\">\u5728Modern-SQL.com\u4e0a\u63a5\u4e0b\u6765<\/span><\/p>\n<\/li>\n<\/ol>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 18px; color: #7a4fd6;\"><strong style=\"outline: 0px;\"><span style=\"outline: 0px; font-family: arial, helvetica, sans-serif;\">\u5e03\u5c14\u53d8\u91cf\u548c\u5224\u65ad<\/span><\/strong><\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">SQLite\u652f\u6301\u201c\u5047\u201d\u5e03\u5c14\u503c\uff1a\u5b83\u63a5\u53d7Boolean\u4f5c\u4e3a\u7c7b\u578b\u7684\u540d\u79f0\uff0c\u4f46\u5b83\u5c06\u5176\u5f53\u4f5c\u6574\u6570\u770b\u5f85\uff08\u8fd9\u4e00\u70b9\u975e\u5e38\u7c7b\u4f3c\u4e8eMySQL\uff09\u3002\u771f\u503ctrue\u548cfalse\u5206\u522b\u7531\u6570\u503c1\u548c0\u8868\u793a\uff08\u8fd9\u4e00\u70b9\u548cC\u8bed\u8a00\u4e00\u6837\uff09\u3002<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u4ece\u7248\u672c3.23.0\u5f00\u59cb\uff0cSQLite\u5c06\u5173\u952e\u5b57true\u548cfalse\u5206\u522b\u7528\u6570\u5b571\u548c0\u8868\u793a\uff0c\u5e76\u652f\u6301is [not] true | false\u7684\u5224\u65ad\u8bed\u53e5\u3002\u73b0\u5728\uff0c\u5b83\u4e0d\u518d\u652f\u6301\u5173\u952e\u5b57unknown\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u4f7f\u7528\u7a7a\u503cnull\u6765\u4ee3\u66ff\uff0c\u56e0\u4e3aunknown\u548cnull\u7684\u5e03\u5c14\u503c\u662f\u4e00\u6837\u7684\u3002<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u5728INSERT\u548cUPDATE\u8bed\u53e5\u4e2d\uff0c\u5b57\u9762\u91cftrue\u548cfalse\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8values\u548cset\u5b50\u53e5\u7684\u53ef\u8bfb\u6027\u3002<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">is [not] true | false\u8fd9\u4e2a\u5224\u65ad\u8bed\u53e5\u5f88\u6709\u7528\uff0c\u5b83\u4e0e\u6bd4\u8f83\u64cd\u4f5c\u7684\u542b\u4e49\u4e0d\u4e00\u6837\uff1a<\/span><\/p>\n<section style=\"margin-top: 24px; margin-bottom: 16px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u6211\u4eec\u6765\u6bd4\u8f83\u4e00\u4e0b<\/span><\/section>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"xml\"><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\">WHERE c <span class=\"code-snippet__tag\" style=\"outline: 0px;\">&lt;&gt;<\/span> FALSE<\/span><\/code><\/pre>\n<\/section>\n<section style=\"margin-top: 24px; margin-bottom: 16px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u548c<\/span><\/section>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"nginx\"><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\"><span class=\"code-snippet__attribute\" style=\"outline: 0px;\">WHERE<\/span> c IS NOT FALSE<\/span><\/code><\/pre>\n<\/section>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u5982\u679cc\u662fnull, \u90a3\u4e48c &lt;&gt; false\u7684\u7ed3\u679c\u662funknown.<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u8fd9\u662f\u56e0\u4e3aWHERE\u5b50\u53e5\u53ea\u63a5\u53d7\u7ed3\u679c\u4e3atrue\u7684\u503c\uff0c\u5b83\u4f1a\u8fc7\u6ee4\u6389\u7ed3\u679c\u4e3afalse\u6216unknown\u7684\u503c\u3002\u8fd9\u6837\uff0c\u5b83\u5c31\u4f1a\u628a\u5bf9\u5e94\u7684\u884c\u4ece\u7ed3\u679c\u4e2d\u53bb\u6389\u3002<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u4e0e\u6b64\u76f8\u5bf9\u5e94\uff0c\u5982\u679cc\u662fnull\uff0c\u90a3\u4e48\uff0cc is not false\u7684\u5224\u65ad\u7ed3\u679c\u662ftrue\u3002\u56e0\u6b64\uff0c\u7b2c\u4e8c\u4e2aWHERE\u5b50\u53e5\u4e5f\u5c06\u5305\u542bc\u662fnull\u7684\u884c\u3002<\/span><\/p>\n<section style=\"margin-top: 24px; margin-bottom: 16px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u8981\u8fbe\u5230\u540c\u6837\u7684\u6548\u679c\uff0c\u60a8\u53ef\u4ee5\u91c7\u7528\u7684\u53e6\u5916\u4e00\u79cd\u65b9\u6cd5\u662f\u589e\u52a0\u5355\u72ec\u5904\u7406null\u503c\u7684\u5b50\u53e5\u3002\u4e5f\u5c31\u662f\u4f7f\u7528\u8bed\u53e5:<\/span><\/section>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"php\"><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\">WHERE c &lt;&gt; <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">FALSE<\/span><\/span><\/code><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\">   <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">OR<\/span> c IS <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">NULL<\/span><\/span><\/code><\/pre>\n<\/section>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u8fd9\u79cd\u5f62\u5f0f\u7684\u8bed\u53e5\u66f4\u957f\u5e76\u4e14\u6709\u4e00\u4e9b\u5197\u4f59\u8bed\u53e5\uff08c\u88ab\u4f7f\u7528\u4e86\u4e24\u6b21\uff09\u3002\u957f\u8bdd\u77ed\u8bf4\uff0c\u53ef\u4ee5\u4f7f\u7528is not false\u5224\u65ad\u6765\u66ff\u4ee3\u8fd9\u4e2aor\u2026is-null\u7684\u8bed\u53e5\u3002\u66f4\u8be6\u7ec6\u7684\u5185\u5bb9\uff0c\u8bf7\u53c2\u8003\u201cBinary Decisions Based on Three-Valued Results\u201d\u3002<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">SQLite\u4e2d\u5bf9\u5e03\u5c14\u5b57\u9762\u91cf\u548c\u5e03\u5c14\u5224\u65ad\u7684\u652f\u6301\u73b0\u5728\u548c\u5176\u4ed6\u5f00\u6e90\u6570\u636e\u5e93\u63a5\u8fd1\uff0c\u552f\u4e00\u7684\u5dee\u8ddd\u662fSQLite\u4e0d\u652f\u6301is[not] unknown\uff08\u4f60\u53ef\u4ee5\u4f7f\u7528is [not] null\u6765\u4ee3\u66ff\uff09\u3002\u6709\u8da3\u7684\u662f\uff0c\u8fd9\u4e9b\u529f\u80fd\u5728\u4e0b\u9762\u63d0\u5230\u7684\u5546\u7528\u4ea7\u54c1\u4e2d\u8fd8\u4e0d\u53ef\u7528\u3002<\/span><\/p>\n<figure style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"margin-right: auto; margin-left: auto; outline: 0px; display: block; border-radius: 5px; background: none #e0e0e0; box-shadow: rgba(0, 0, 0, 0.043) 0px 0px 2.1px, rgba(0, 0, 0, 0.063) 0px 0px 5px, rgba(0, 0, 0, 0.075) 0px 0px 9.4px, rgba(0, 0, 0, 0.09) 0px 0px 16.8px, rgba(0, 0, 0, 0.11) 0px 0px 31.3px, rgba(0, 0, 0, 0.15) 0px 0px 75px; width: 575.438px !important; visibility: visible !important;\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2024\/03\/wxsync-2024-03-22444efde7d7078a9ae1a81d4cab792f.jpeg\" data-imgfileid=\"100020680\" data-ratio=\"0.35324675324675325\" data-w=\"770\" \/><\/figure>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">0\uff1a\u53ea\u652f\u6301true,false.\u4e0d\u652f\u6301notknown\uff0c\u5982\u679c\u9700\u8981\uff0c\u7528null\u4ee3\u66ff<\/span><\/p>\n<\/section>\n<section style=\"outline: 0px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; background-color: #ffffff;\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\">\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">1\uff1a\u4e0d\u652f\u6301is [not] unknown,\u5982\u679c\u9700\u8981\uff0c\u7528is [not] null\u4ee3\u66ff<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; color: #7a4fd6;\"><strong style=\"outline: 0px;\"><span style=\"outline: 0px; font-family: arial, helvetica, sans-serif; font-size: 18px;\">\u7a97\u53e3\u51fd\u6570<\/span><\/strong><\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">SQLite 3.25.0\u5f15\u5165\u4e86\u7a97\u53e3\u51fd\u6570\u3002\u5982\u679c\u4f60\u77e5\u9053\u7a97\u53e3\u51fd\u6570\uff0c\u90a3\u4e48\u4e5f\u77e5\u9053\u8fd9\u662f\u4e00\u4ef6\u5927\u4e8b\u3002\u5982\u679c\u4f60\u4e0d\u4e86\u89e3\u7a97\u53e3\u529f\u80fd\uff0c\u8bf7\u4f60\u81ea\u5df1\u5b66\u4e60\u5982\u4f55\u4f7f\u7528\u3002\u8fd9\u7bc7\u6587\u7ae0\u4e0d\u4f1a\u5177\u4f53\u89e3\u91ca\u7a97\u53e3\u51fd\u6570\uff0c\u4f46\u8bf7\u76f8\u4fe1\uff1a\u5b83\u662f\u6700\u91cd\u8981\u7684\u201c\u73b0\u4ee3\u201dSQL\u7279\u6027\u3002<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">SQLite\u5bf9over\u5b50\u53e5\u7684\u652f\u6301\u4e0e\u5176\u4ed6\u6570\u636e\u5e93\u975e\u5e38\u63a5\u8fd1\u3002\u552f\u4e00\u503c\u5f97\u6ce8\u610f\u7684\u9650\u5236\u662frange\u8bed\u53e5\u4e0d\u652f\u6301\u6570\u5b57\u6216\u95f4\u9694\u8ddd\u79bb\uff08\u4ec5\u652f\u6301current row\u548cunbounded preceding|following\uff09\u3002\u5728\u53d1\u5e03sqlite 3.25.0\u65f6,SQL Server\u548cPostgreSQL\u5177\u6709\u540c\u6837\u7684\u9650\u5236\u3002PostgreSQL 11\u6d88\u9664\u4e86\u8fd9\u4e00\u9650\u5236\u3002<\/span><\/p>\n<figure style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"margin-right: auto; margin-left: auto; outline: 0px; display: block; border-radius: 5px; background: none #e0e0e0; box-shadow: rgba(0, 0, 0, 0.043) 0px 0px 2.1px, rgba(0, 0, 0, 0.063) 0px 0px 5px, rgba(0, 0, 0, 0.075) 0px 0px 9.4px, rgba(0, 0, 0, 0.09) 0px 0px 16.8px, rgba(0, 0, 0, 0.11) 0px 0px 31.3px, rgba(0, 0, 0, 0.15) 0px 0px 75px; width: 575.438px !important; visibility: visible !important;\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2024\/03\/wxsync-2024-03-a4bc2cc06198703e32066b6ff466a9ec.jpeg\" data-imgfileid=\"100020677\" data-ratio=\"0.6818791946308724\" data-w=\"745\" \/><\/figure>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">0\uff1a\u6ca1\u6709\u53d8\u5316<\/span><\/p>\n<\/section>\n<section style=\"outline: 0px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; background-color: #ffffff;\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\">\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">1\uff1aRange\u8303\u56f4\u5b9a\u4e49\u4e0d\u652f\u6301datetime\u7c7b\u578b<\/span><\/p>\n<\/section>\n<section style=\"outline: 0px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; background-color: #ffffff;\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\">\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">2\uff1aRange\u8303\u56f4\u4e0d\u63a5\u53d7<\/span><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u5173\u952e\u5b57 (\u53ea\u652f\u6301unbounded\u548ccurrent row)<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">SQLite\u5bf9\u4e8e\u7a97\u53e3\u51fd\u6570\u7684\u652f\u6301\u5728\u4e1a\u754c\u662f\u9886\u5148\u7684\u3002\u5b83\u4e0d\u652f\u6301\u7684\u529f\u80fd\u5728\u5176\u4ed6\u4e00\u4e9b\u4e3b\u8981\u4ea7\u54c1\u4e2d\u4e5f\u540c\u6837\u4e0d\u652f\u6301\uff08\u5728\u805a\u5408\u4e2d\u8bed\u53e5\u4e2d\u7684distinct\uff0cwidth_bucket\uff0c respect|ignore nulls\u548cfrom first|last\u7b49\u8bed\u53e5\uff09\u3002<\/span><\/p>\n<figure style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"margin-right: auto; margin-left: auto; outline: 0px; display: block; border-radius: 5px; background: none #e0e0e0; box-shadow: rgba(0, 0, 0, 0.043) 0px 0px 2.1px, rgba(0, 0, 0, 0.063) 0px 0px 5px, rgba(0, 0, 0, 0.075) 0px 0px 9.4px, rgba(0, 0, 0, 0.09) 0px 0px 16.8px, rgba(0, 0, 0, 0.11) 0px 0px 31.3px, rgba(0, 0, 0, 0.15) 0px 0px 75px; width: 575.438px !important; visibility: visible !important;\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2024\/03\/wxsync-2024-03-af350d6e2b65723c84e128d968a79c12.jpeg\" data-imgfileid=\"100020679\" data-ratio=\"0.9906790945406125\" data-w=\"751\" \/><\/figure>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">0\uff1a\u540c\u6837\u6ca1\u6709ORDER BY \u8bed\u53e5<\/span><\/p>\n<\/section>\n<section style=\"outline: 0px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; background-color: #ffffff;\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\">\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">1\uff1a\u4e0d\u5141\u8bb8\u8d1f\u504f\u79fb\u91cf\uff0cnulls\u7684\u7279\u5b9a\u5904\u7406\uff1alead(<\/span><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">, &#8216;IGNORE NULLS&#8217;)\uff0c\u8fd9\u91cc\u662f\u5b57\u7b26\u4e32\u53c2\u6570<\/span><\/p>\n<\/section>\n<section style=\"outline: 0px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; background-color: #ffffff;\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\">\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">2\uff1a\u6ca1\u6709\u7f3a\u7701\u503c(\u7b2c\u4e09\u4e2a\u53c2\u6570)\uff0c\u4e0d\u652f\u6301respect|ignore nulls\u8bed\u53e5<\/span><\/p>\n<\/section>\n<section style=\"outline: 0px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; background-color: #ffffff;\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\">\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">3\uff1a\u4e0d\u5141\u8bb8\u8d1f\u504f\u79fb\u91cf\uff0c\u4e0d\u652f\u6301ignore nulls\u8bed\u53e5<\/span><\/p>\n<\/section>\n<section style=\"outline: 0px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; background-color: #ffffff;\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\">\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">4\uff1a\u4e0d\u5141\u8bb8\u8d1f\u504f\u79fb\u91cf<\/span><\/p>\n<\/section>\n<section style=\"outline: 0px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; background-color: #ffffff;\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\">\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">5\uff1a\u4e0d\u652f\u6301respect|ignore nulls\u8bed\u53e5<\/span><\/p>\n<\/section>\n<section style=\"outline: 0px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; background-color: #ffffff;\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\">\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">6\uff1a\u4e0d\u5141\u8bb8\u8d1f\u504f\u79fb\u91cf\uff0c\u4e0d\u652f\u6301respect|ignore nulls\u8bed\u53e5<\/span><\/p>\n<\/section>\n<section style=\"outline: 0px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; background-color: #ffffff;\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\">\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">7\uff1anulls\u7684\u7279\u5b9a\u5904\u7406\uff1afirst_value(<\/span><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">, 1, null, &#8216;IGNORE NULLS&#8217;) \uff0c\u8fd9\u91cc\u662f\u5b57\u7b26\u4e32\u53c2\u6570\u3002<\/span><\/p>\n<\/section>\n<section style=\"outline: 0px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; background-color: #ffffff;\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\">\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">8\uff1a\u4e0d\u652f\u6301ignore nulls\u8bed\u53e5<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">9\uff1a\u4e0d\u652f\u6301ignore nulls\u8bed\u53e5\u548cfrom last\u8bed\u53e5<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 18px; color: #7a4fd6;\"><strong style=\"outline: 0px;\"><span style=\"outline: 0px; font-family: arial, helvetica, sans-serif;\">\u8fc7\u6ee4\u8bed\u53e5<\/span><\/strong><\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u867d\u7136filter\u8bed\u53e5\u53ea\u662f\u8bed\u6cd5\u7cd6\u2014\u2014\u4f60\u4e5f\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u4f7f\u7528\u8868\u8fbe\u5f0f\u6765\u83b7\u5f97\u76f8\u540c\u7684\u7ed3\u679c\u2014\u2014\u6211\u8ba4\u4e3a\u5b83\u4e5f\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u8bed\u6cd5\u7cd6\uff0c\u56e0\u4e3a\u5b83\u80fd\u4f7f\u4eba\u4eec\u66f4\u52a0\u5bb9\u6613\u5730\u5b66\u4e60\u548c\u7406\u89e3SQL\u8bed\u53e5\u3002<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 16px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u770b\u770b\u4e0b\u9762\u7684select\u5b50\u53e5\uff0c\u60a8\u89c9\u5f97\u54ea\u4e00\u4e2a\u66f4\u5bb9\u6613\u7406\u89e3\uff1f<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"sql\"><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\"><span class=\"code-snippet__keyword\" style=\"outline: 0px;\">SELECT<\/span> <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">SUM<\/span>(revenue) total_revenue<\/span><\/code><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\">     , <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">SUM<\/span>(<span class=\"code-snippet__keyword\" style=\"outline: 0px;\">CASE<\/span> <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">WHEN<\/span> product = <span class=\"code-snippet__number\" style=\"outline: 0px;\">1<\/span> <\/span><\/code><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\">                <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">THEN<\/span> revenue<\/span><\/code><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\">            <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">END<\/span><\/span><\/code><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\">          ) prod1_revenue<\/span><\/code><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\">   ...<\/span><\/code><\/pre>\n<\/section>\n<section style=\"margin-top: 24px; margin-bottom: 16px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u548c<\/span><\/section>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"sql\"><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\"><span class=\"code-snippet__keyword\" style=\"outline: 0px;\">SELECT<\/span> <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">SUM<\/span>(revenue) total_revenue<\/span><\/code><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\">     , <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">SUM<\/span>(revenue) FILTER(<span class=\"code-snippet__keyword\" style=\"outline: 0px;\">WHERE<\/span> product = <span class=\"code-snippet__number\" style=\"outline: 0px;\">1<\/span>) prod1_revenue<\/span><\/code><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\">   ...<\/span><\/code><\/pre>\n<\/section>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u6b64\u793a\u4f8b\u5f88\u597d\u5730\u603b\u7ed3\u4e86filter\u5b50\u53e5\u7684\u4f5c\u7528\uff1a\u5b83\u662f\u805a\u5408\u51fd\u6570\u7684\u540e\u7f00\uff0c\u53ef\u4ee5\u5728\u8fdb\u884c\u805a\u5408\u4e4b\u524d\u6839\u636e\u7279\u5b9a\u6761\u4ef6\uff0c\u8fc7\u6ee4\u6389\u76f8\u5e94\u7684\u884c\u3002pivot\u6280\u672f\u662ffilter\u5b50\u53e5\u6700\u5e38\u89c1\u7684\u7528\u4f8b\u3002\u8fd9\u5305\u62ec\u5c06\u5b9e\u4f53\u5c5e\u6027\u503c\uff08EAV\uff09\u6a21\u578b\u4e2d\u7684\u5c5e\u6027\u8f6c\u6362\u4e3a\u8868\u683c\u7684\u5217\uff0c\u5982\u679c\u60f3\u4e86\u89e3\u66f4\u591a\u7684\u5185\u5bb9\uff0c\u53ef\u4ee5\u53c2\u8003\u94fe\u63a5\u201cfilter-Selective Aggregates\u201d\uff08https:\/\/modern-sql.com\/feature\/filter\uff09\u3002<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">SQLite \u4ece\u7248\u672c3.25.0\u5f00\u59cb\uff0c\u5728\u4f7f\u7528over\u5b50\u53e5\u7684\u805a\u5408\u51fd\u6570\u4e2d\u652f\u6301\u4e86filter\u5b50\u53e5\uff0c\u4f46\u662f\u5728\u4f7f\u7528group by\u5b50\u53e5\u7684\u805a\u5408\u51fd\u6570\u4e2d\u8fd8\u4e0d\u652f\u6301\u3002\u4e0d\u5e78\u7684\u662f\uff0c\u8fd9\u610f\u5473\u7740\u60a8\u4ecd\u7136\u65e0\u6cd5\u5728SQLite\u4e2d\u4f7f\u7528filter\u8bed\u53e5\u6765\u5904\u7406\u4e0a\u8ff0\u60c5\u51b5\u3002\u4f60\u5fc5\u987b\u50cf\u4ee5\u524d\u4e00\u6837\u4f7f\u7528case\u8868\u8fbe\u5f0f\u3002\u6211\u771f\u7684\u5e0c\u671bSQLite\u5728\u8fd9\u4e00\u70b9\u4e0a\u80fd\u5c3d\u5feb\u505a\u5230\u3002<\/span><\/p>\n<figure style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"margin-right: auto; margin-left: auto; outline: 0px; display: block; border-radius: 5px; background: none #e0e0e0; box-shadow: rgba(0, 0, 0, 0.043) 0px 0px 2.1px, rgba(0, 0, 0, 0.063) 0px 0px 5px, rgba(0, 0, 0, 0.075) 0px 0px 9.4px, rgba(0, 0, 0, 0.09) 0px 0px 16.8px, rgba(0, 0, 0, 0.11) 0px 0px 31.3px, rgba(0, 0, 0, 0.15) 0px 0px 75px; width: 575.438px !important; visibility: visible !important;\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2024\/03\/wxsync-2024-03-01994033c064b14a180c68b8c819b77a.jpeg\" data-imgfileid=\"100020676\" data-ratio=\"0.31605562579013907\" data-w=\"791\" \/><\/figure>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 18px; color: #7a4fd6;\"><strong style=\"outline: 0px;\"><span style=\"outline: 0px; font-family: arial, helvetica, sans-serif;\">Insert \u2026 on conflict (\u201cUpsert\u201d)<\/span><\/strong><\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">SQLite \u4ece\u7248\u672c3.24.0\u5f00\u59cb\uff0c\u5f15\u5165\u4e86\u201cupsert\u201d\u6982\u5ff5\uff1a\u5b83\u662f\u4e00\u4e2ainsert\u8bed\u53e5\uff0c\u53ef\u4ee5\u4f18\u96c5\u5730\u5904\u7406\u4e3b\u952e\u548c\u552f\u4e00\u7ea6\u675f\u7684\u51b2\u7a81\u3002\u60a8\u53ef\u4ee5\u9009\u62e9\u5ffd\u7565\u8fd9\u4e9b\u51b2\u7a81\uff08\u5728on conflict\u8bed\u53e5\u4e2d\u4ec0\u4e48\u90fd\u4e0d\u505a\uff09\u6216\u8005\u66f4\u65b0\u5f53\u524d\u884c\uff08\u5728on conflict\u8bed\u53e5\u4e2d\u6267\u884c\u66f4\u65b0\u64cd\u4f5c\uff09\u3002<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u8fd9\u662f\u4e00\u4e2a\u7279\u6709\u7684SQL\u6269\u5c55\uff0c\u5373\u5b83\u4e0d\u662f\u6807\u51c6SQL\u7684\u4e00\u90e8\u5206\uff0c\u56e0\u6b64\u5728\u4e0b\u9762\u7684\u77e9\u9635\u4e2d\u662f\u7070\u8272\u7684\u3002\u4f46\u662f\uff0cSQLite\u9075\u5b88\u4e0ePostgreSQL\u76f8\u540c\u7684\u8bed\u6cd5\u6765\u5b9e\u73b0\u6b64\u529f\u80fd0\u3002\u8be5\u6807\u51c6\u63d0\u4f9b\u4e86\u5bf9merge\u8bed\u53e5\u7684\u652f\u6301\u3002<\/span><\/p>\n<section style=\"margin-top: 24px; margin-bottom: 16px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u4e0ePostgreSQL\u4e0d\u540c\uff0cSQLite\u5728\u4ee5\u4e0b\u8bed\u53e5\u4e2d\u5b58\u5728\u95ee\u9898\u3002<\/span><\/section>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"sql\"><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\"><span class=\"code-snippet__keyword\" style=\"outline: 0px;\">INSERT<\/span> <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">INTO<\/span> target<\/span><\/code><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\"><span class=\"code-snippet__keyword\" style=\"outline: 0px;\">SELECT<\/span> *<\/span><\/code><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\">  <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">FROM<\/span> <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">source<\/span><\/span><\/code><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\">    <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">ON<\/span> CONFLICT (<span class=\"code-snippet__keyword\" style=\"outline: 0px;\">id<\/span>)<\/span><\/code><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\">    <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">DO<\/span> <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">UPDATE<\/span> <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">SET<\/span> val = excluded.val<\/span><\/code><\/pre>\n<\/section>\n<section style=\"margin-top: 24px; margin-bottom: 16px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u6839\u636e\u8bf4\u660e\u6587\u6863\uff0c\u8fd9\u662f\u56e0\u4e3a\u89e3\u6790\u5668\u65e0\u6cd5\u5224\u65ad\u5173\u952e\u5b57ON\u662fSELECT\u8bed\u53e5\u7684\u8fde\u63a5\u7ea6\u675f\u8fd8\u662fupsert\u5b50\u53e5\u7684\u5f00\u5934\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u5411\u67e5\u8be2\u4e2d\u6dfb\u52a0\u5b50\u53e5\u6765\u89e3\u51b3\uff0c\u4f8b\u5982where true\u3002<\/span><\/section>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"sql\"><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\"><span class=\"code-snippet__keyword\" style=\"outline: 0px;\">INSERT<\/span> <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">INTO<\/span> target<\/span><\/code><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\"><span class=\"code-snippet__keyword\" style=\"outline: 0px;\">SELECT<\/span> *<\/span><\/code><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\">  <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">FROM<\/span> <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">source<\/span><\/span><\/code><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\"> <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">WHERE<\/span> <span class=\"code-snippet__literal\" style=\"outline: 0px;\">true<\/span><\/span><\/code><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\">    <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">ON<\/span> CONFLICT (<span class=\"code-snippet__keyword\" style=\"outline: 0px;\">id<\/span>)<\/span><\/code><code style=\"outline: 0px;\"><span class=\"code-snippet_outer\" style=\"outline: 0px;\">    <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">DO<\/span> <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">UPDATE<\/span> <span class=\"code-snippet__keyword\" style=\"outline: 0px;\">SET<\/span> val = excluded.val<\/span><\/code><\/pre>\n<\/section>\n<figure style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"margin-right: auto; margin-left: auto; outline: 0px; display: block; border-radius: 5px; background: none #e0e0e0; box-shadow: rgba(0, 0, 0, 0.043) 0px 0px 2.1px, rgba(0, 0, 0, 0.063) 0px 0px 5px, rgba(0, 0, 0, 0.075) 0px 0px 9.4px, rgba(0, 0, 0, 0.09) 0px 0px 16.8px, rgba(0, 0, 0, 0.11) 0px 0px 31.3px, rgba(0, 0, 0, 0.15) 0px 0px 75px; width: 575.438px !important; visibility: visible !important;\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2024\/03\/wxsync-2024-03-0a80e5c68b60ab81ecf6e410f40c39cb.jpeg\" data-imgfileid=\"100020678\" data-ratio=\"0.42455242966751916\" data-w=\"782\" \/><\/figure>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">0\uff1a\u540c\u6837\u8bb0\u5f55insert\u3001update\u3001delete\u548cmerge\u64cd\u4f5c\u7684\u9519\u8bef\u4fe1\u606f (\u201cDML error logging\u201d)<\/span><\/p>\n<\/section>\n<section style=\"outline: 0px; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; letter-spacing: 0.544px; background-color: #ffffff;\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\">\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">1\uff1aOn conflict\u8bed\u53e5\u4e0d\u80fd\u7d27\u6328\u67e5\u8be2\u7684from\u8bed\u53e5\uff0c\u5982\u679c\u9700\u8981\uff0c\u53ef\u4ee5\u6dfb\u52a0 \u00a0where true\u8bed\u53e5\u6765\u5206\u9694\u3002<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 18px; color: #7a4fd6;\"><strong style=\"outline: 0px;\"><span style=\"outline: 0px; font-family: arial, helvetica, sans-serif;\">\u91cd\u547d\u540d\u5217<\/span><\/strong><\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">SQLite\u5f15\u5165\u7684\u53e6\u4e00\u4e2a\u7279\u6709\u529f\u80fd\u662f\u91cd\u547d\u540d\u57fa\u51c6\u6570\u636e\u5e93\u8868\u4e2d\u7684\u52171\u3002\u6807\u51c6\u7684SQL\u4e0d\u652f\u6301\u6b64\u7c7b\u529f\u80fd2\u3002<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">SQLite\u9075\u5faa\u5176\u4ed6\u4ea7\u54c1\u5e38\u7528\u7684\u8bed\u6cd5\u6765\u91cd\u547d\u540d\u5217\uff1a<\/span><\/p>\n<blockquote style=\"outline: 0px; color: var(--weui-fg-1);\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"outline: 0px; text-align: left;\">ALTER TABLE \u2026 RENAME COLUMN \u2026 TO<\/p>\n<\/blockquote>\n<figure style=\"outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img decoding=\"async\" class=\"rich_pages wxw-img\" style=\"margin-right: auto; margin-left: auto; outline: 0px; display: block; border-radius: 5px; background: none #e0e0e0; box-shadow: rgba(0, 0, 0, 0.043) 0px 0px 2.1px, rgba(0, 0, 0, 0.063) 0px 0px 5px, rgba(0, 0, 0, 0.075) 0px 0px 9.4px, rgba(0, 0, 0, 0.09) 0px 0px 16.8px, rgba(0, 0, 0, 0.11) 0px 0px 31.3px, rgba(0, 0, 0, 0.15) 0px 0px 75px; width: 575.438px !important; visibility: visible !important;\" src=\"http:\/\/www.zhushiyao.com\/wp-content\/uploads\/2024\/03\/wxsync-2024-03-e595a1993d830870eb61396c01b2c815.png\" data-imgfileid=\"100020681\" data-ratio=\"0.32694938440492477\" data-w=\"731\" \/><\/figure>\n<blockquote style=\"outline: 0px; color: var(--weui-fg-1);\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"outline: 0px; text-align: left;\">0\uff1a\u8bf7\u67e5\u9605 sp_rename.<\/p>\n<\/blockquote>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 18px; color: #7a4fd6;\"><strong style=\"outline: 0px;\"><span style=\"outline: 0px; font-family: arial, helvetica, sans-serif;\">\u5176\u4ed6\u6d88\u606f<\/span><\/strong><\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\u57282018\u5e74\uff0cSQLite\u9664\u4e86\u5728SQL\u8bed\u6cd5\u4e0a\u7684\u53d8\u5316\uff0c\u8fd8\u6709\u4e00\u4e9b\u5e94\u7528\u7a0b\u5e8f\u63a5\u53e3\uff08API\uff09\u7684\u53d8\u5316\u3002\u4f60\u53ef\u4ee5\u67e5\u9605sqlite.com\uff08https:\/\/www.sqlite.org\/news.html\uff09\u4e0a\u7684\u65b0\u95fb\u90e8\u5206\u6765\u4e86\u89e3\u66f4\u8be6\u7ec6\u7684\u6d88\u606f\u3002<\/span><\/p>\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px; font-size: 18px; color: #7a4fd6;\"><strong style=\"outline: 0px;\"><span style=\"outline: 0px; font-family: arial, helvetica, sans-serif;\">\u811a\u6807:<\/span><\/strong><\/span><\/p>\n<ul class=\"list-paddingleft-1\" style=\"padding-left: 1.5em; outline: 0px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<li style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px;\">0\uff1aSQLite\u901a\u5e38\u9075\u5faaPostgreSQL\u8bed\u6cd5\uff0cRichard Hipp\u5c06\u6b64\u79f0\u4e3aPostgreSQL\u4f1a\u600e\u4e48\u505a\uff08WWPD\uff09\u3002<\/span><\/p>\n<\/li>\n<li style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\n<p style=\"margin-top: 24px; margin-bottom: 24px; outline: 0px; text-align: left;\"><span style=\"outline: 0px;\">1\uff1a\u57fa\u51c6\u6570\u636e\u5e93\u8868\u662f\u6307\u7528Create table\u8bed\u53e5\u521b\u5efa\u7684\u6570\u636e\u5e93\u8868\u3002\u6d3e\u751f\u7684\u6570\u636e\u5e93\u8868\uff08\u5982Select\u8bed\u53e5\u8fd4\u56de\u7684\u67e5\u8be2\u7ed3\u679c\u96c6\uff09\u4e2d\u7684\u5217\u540d\u53ef\u4ee5\u901a\u8fc7SELECT\u8bed\u53e5\u3001FROM\u8bed\u53e5\u6216WITH\u8bed\u53e5\u6765\u8fdb\u884c\u6539\u53d8<\/span><\/p>\n<\/li>\n<li style=\"outline: 0px; font-size: 16px; font-family: arial, helvetica, sans-serif;\">\n<section style=\"margin-top: 24px; margin-bottom: 16px; outline: 0px; text-align: left;\"><span style=\"outline: 0px;\">2\uff1a\u636e\u6211\u6240\u77e5\uff0c\u4e5f\u8bb8\u53ef\u4ee5\u901a\u8fc7\u53ef\u66f4\u65b0\u89c6\u56fe\u6216\u6d3e\u751f\u7684\u5217\u6765\u6a21\u62df\u8be5\u529f\u80fd\u3002<\/span><span style=\"outline: 0px; color: rgba(0, 0, 0, 0.5); font-family: system-ui, -apple-system, 'system-ui', 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif; font-size: 15px; letter-spacing: 0.544px; text-align: center; word-spacing: 2px;\">\u00a0<\/span><\/section>\n<\/li>\n<\/ul>\n<p style=\"margin-bottom: 0px; padding-top: 8px; padding-bottom: 8px; outline: 0px; color: #000000; font-family: Optima, 'Microsoft YaHei', PingFangSC-regular, serif; font-size: 16px; letter-spacing: 0em; text-indent: 0em; text-wrap: wrap; background-color: #ffffff; line-height: 1.8em;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"color: #b2b2b2; font-family: arial, helvetica, sans-serif; font-size: 14px; letter-spacing: 0.544px; text-align: left;\">\u6587\u7ae0\u6765\u6e90\uff1a<\/span><span style=\"color: #b2b2b2; font-family: arial, helvetica, sans-serif; font-size: 14px; letter-spacing: 0.544px; text-align: left;\">\u7f51\u7edc<\/span><\/p>\n<\/section>\n<\/section>\n<p style=\"display: none;\">\n<blockquote><p>\u8f6c\u81ea:<\/p><\/blockquote>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>SQLite \u662f\u4e00\u4e2a\u88ab\u5927\u5bb6\u4f4e\u4f30\u7684\u6570\u636e\u5e93\uff0c\u4f46\u6709\u4e9b\u4eba\u8ba4\u4e3a\u5b83\u662f\u4e00\u4e2a\u4e0d\u9002\u5408\u751f\u4ea7\u73af\u5883\u4f7f\u7528\u7684\u73a9\u5177\u6570\u636e\u5e93\u3002\u4e8b\u5b9e\u4e0a\uff0cSQLit &hellip; <a href=\"http:\/\/www.zhushiyao.com\/?p=115306\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cSQLite 3.22.0 -3.26.0 2018 \u5e74\u65b0\u589e\u52a0\u7684 SQL \u529f\u80fd\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/115306"}],"collection":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=115306"}],"version-history":[{"count":2,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/115306\/revisions"}],"predecessor-version":[{"id":115308,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=\/wp\/v2\/posts\/115306\/revisions\/115308"}],"wp:attachment":[{"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=115306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=115306"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zhushiyao.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=115306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}