{"id":88624,"date":"2026-08-01T13:56:44","date_gmt":"2026-08-01T05:56:44","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/88624.html"},"modified":"2026-08-01T13:56:44","modified_gmt":"2026-08-01T05:56:44","slug":"2026%e5%b9%b4%e7%89%88-sql%e5%ad%a6%e4%b9%a0%e6%96%87%e6%a1%a3","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/88624.html","title":{"rendered":"2026\u5e74\u7248-SQL\u5b66\u4e60\u6587\u6863"},"content":{"rendered":"<p>\u5f80\u671f\u94fe\u63a5&#xff1a;<\/p>\n<p>SQL\u5b66\u4e60\u6587\u6863-CSDN\u535a\u5ba2<\/p>\n<p>\u5173\u7cfb\u6570\u636e\u5e93\u6807\u51c6\u8bed\u8a00&#xff08;SQL&#xff09;- \u8f6f\u8003\u5907\u6218&#xff08;\u4e09\u5341\u4e00&#xff09;-CSDN\u535a\u5ba2<\/p>\n<p>\u6570\u636e\u5e93\u7cfb\u7edf &#8211; \u6c47\u603b\u7bc7-CSDN\u535a\u5ba2<\/p>\n<p>\u6570\u636e\u5e93\u4e8b\u52a1\u4e0e\u5e76\u53d1\u63a7\u5236 &#8211; \u8f6f\u8003\u5907\u6218&#xff08;\u4e09\u5341\u4e8c&#xff09;-CSDN\u535a\u5ba2<\/p>\n<p>\u5206\u5e03\u5f0f\u6570\u636e\u5e93 &#8211; \u8f6f\u8003\u5907\u6218&#xff08;\u4e09\u5341\u516d&#xff09;-CSDN\u535a\u5ba2<\/p>\n<p>\u6570\u636e\u5e93\u57fa\u7840\u6982\u5ff5\u4e0e\u4f53\u7cfb\u7ed3\u6784 &#8211; \u8f6f\u8003\u5907\u6218&#xff08;\u4e8c\u5341\u4e5d&#xff09;-CSDN\u535a\u5ba2<\/p>\n<p>\u6570\u636e\u5e93\u5b89\u5168\u6027\u4e0e\u5b8c\u6574\u6027 &#8211; \u8f6f\u8003\u5907\u6218&#xff08;\u4e09\u5341\u4e09&#xff09;-CSDN\u535a\u5ba2<\/p>\n<p>\u6570\u636e\u5e93\u8bbe\u8ba1 &#8211; \u8f6f\u8003\u5907\u6218&#xff08;\u4e94\u5341\u4e00&#xff09;-CSDN\u535a\u5ba2<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"3152\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801055640-6a6d8a9897ec8.png\" width=\"1921\" \/><\/p>\n<h2 style=\"background-color:transparent;margin-left:0px;margin-right:0px;text-align:justify\"><span style=\"color:#7030a0\">\u7b2c 00 \u7ae0 \u00b7 \u5e8f\u8a00\u4e0e\u77e5\u8bc6\u5730\u56fe<\/span><\/h2>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">0.1 2026 \u5e74\u7684 SQL \u884c\u4e1a\u683c\u5c40<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">SQL \u6838\u5fc3\u8bed\u6cd5\u51e0\u5341\u5e74\u76f8\u5bf9\u7a33\u5b9a&#xff0c;\u4f46\u300c\u5408\u683c\u7ebf\u300d\u6301\u7eed\u4e0a\u79fb&#xff0c;\u884c\u4e1a\u683c\u5c40\u51fa\u73b0\u660e\u786e\u5206\u5316&#xff1a;<\/span><\/p>\n<p style=\"text-align:left\"><span style=\"color:#8eaadb\">\u7a97\u53e3\u51fd\u6570\u3001CTE \u5df2\u6210\u4e3a\u57fa\u7840\u80fd\u529b&#xff1a;\u6570\u636e\u5206\u6790\u3001\u6570\u4ed3\u5f00\u53d1\u3001\u540e\u7aef\u5f00\u53d1\u5c97\u4f4d\u5747\u9ed8\u8ba4\u8981\u6c42\u638c\u63e1&#xff0c;\u4e0d\u518d\u662f\u300c\u9ad8\u7ea7\u9009\u4fee\u300d\u3002<\/span><\/p>\n<p style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5f15\u64ce\u751f\u6001\u5206\u5316\u660e\u786e&#xff1a;<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">OLTP \u9886\u57df&#xff1a;PostgreSQL \u51ed\u501f JSONB\u3001pgvector \u5411\u91cf\u6269\u5c55\u3001\u9ad8\u5ea6\u7684\u6807\u51c6\u517c\u5bb9\u6027&#xff0c;\u6210\u4e3a\u65b0\u9879\u76ee\u7684\u9ed8\u8ba4\u9009\u62e9&#xff0c;2026 \u5e74\u5f00\u53d1\u8005\u6e17\u900f\u7387\u7a81\u7834 55%&#xff0c;\u65b0\u589e\u9879\u76ee\u9009\u578b\u6bd4\u4f8b\u8fbe MySQL \u7684 3 \u500d&#xff1b;MySQL \u4ecd\u5728\u5b58\u91cf Web \u751f\u6001\u5360\u636e\u4e3b\u6d41\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u672c\u5730\u5206\u6790\u9886\u57df&#xff1a;DuckDB \u6210\u4e3a\u300c\u5d4c\u5165\u5f0f\u6570\u4ed3\u300d\u4e8b\u5b9e\u6807\u51c6&#xff0c;\u53ef\u76f4\u63a5\u67e5\u8be2\u672c\u5730\u6587\u4ef6&#xff0c;\u5f00\u53d1\u6548\u7387\u4e0e\u6027\u80fd\u53cc\u4f18&#xff0c;\u662f\u672c\u5730\u6570\u636e\u5206\u6790\u3001\u5355\u5143\u6d4b\u8bd5\u3001\u8fb9\u7f18\u8ba1\u7b97\u7684\u9996\u9009\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4e91\u6570\u4ed3&#xff1a;Snowflake\u3001BigQuery\u3001Redshift \u6301\u7eed\u4e3b\u5bfc\u4e91\u7aef\u5927\u89c4\u6a21\u5206\u6790\u573a\u666f&#xff0c;\u626b\u63cf\u6210\u672c\u3001\u5206\u533a\u88c1\u526a\u662f\u6838\u5fc3\u4f18\u5316\u70b9\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">HTAP \u4e0e\u5206\u5e03\u5f0f&#xff1a;TiDB\u3001OceanBase\u3001PolarDB \u7b49\u56fd\u4ea7\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u5feb\u901f\u5d1b\u8d77&#xff0c;\u517c\u987e\u4e8b\u52a1\u4e0e\u5206\u6790\u80fd\u529b&#xff0c;\u4fe1\u521b\u573a\u666f\u5e94\u7528\u5e7f\u6cdb\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5b9e\u65f6\u5206\u6790&#xff1a;ClickHouse\u3001StarRocks \u4e3b\u5bfc PB \u7ea7\u5b9e\u65f6 OLAP \u573a\u666f\u3002<\/span><\/li>\n<\/ul>\n<p style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6807\u51c6\u4e0e\u843d\u5730&#xff1a;\u6700\u65b0\u5b8c\u6574\u7248\u6807\u51c6\u4ecd\u662f SQL:2023&#xff0c;\u539f\u751f JSON\u3001\u5c5e\u6027\u56fe\u67e5\u8be2 SQL\/PGQ\u3001\u591a\u7ef4\u805a\u5408\u7b49\u7279\u6027\u6301\u7eed\u843d\u5730&#xff0c;\u4f46\u5404\u5f15\u64ce\u8fdb\u5ea6\u5dee\u5f02\u8f83\u5927\u3002<\/span><\/p>\n<p style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5de5\u4f5c\u6a21\u5f0f\u53d8\u9769&#xff1a;AI \u8f85\u52a9\u5199 SQL \u5168\u9762\u666e\u53ca&#xff0c;72% \u7684\u6570\u636e\u56e2\u961f\u5df2\u5c06 AI \u7f16\u7801\u878d\u5165\u65e5\u5e38\u6d41\u7a0b&#xff1b;\u9a8c\u7ed3\u679c\u3001\u63a7\u8d28\u91cf\u3001\u61c2\u903b\u8f91 \u6bd4\u300c\u624b\u5199 SQL \u901f\u5ea6\u300d\u66f4\u91cd\u8981\u3002<\/span><\/p>\n<p style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5de5\u7a0b\u5316\u6210\u719f&#xff1a;\u5206\u6790\u5de5\u7a0b\u6210\u4e3a\u72ec\u7acb\u5c97\u4f4d\u65b9\u5411&#xff0c;dbt \u7b49\u5de5\u5177\u5c06 SQL \u4ece\u300c\u67e5\u8be2\u8bed\u53e5\u300d\u5347\u7ea7\u4e3a\u300c\u53ef\u6d4b\u8bd5\u3001\u53ef\u590d\u7528\u3001\u53ef\u8ffd\u6eaf\u7684\u6570\u636e\u7ba1\u9053\u300d\u3002<\/span><\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">0.2 \u5206\u5c97\u4f4d\u5b66\u4e60\u4fa7\u91cd\u70b9<\/span><\/h3>\n<table cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5c97\u4f4d\u65b9\u5411<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6838\u5fc3\u638c\u63e1\u6a21\u5757<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6df1\u5165\u65b9\u5411<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#e2efd9;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u540e\u7aef\u5f00\u53d1<\/span><\/p>\n<\/td>\n<td style=\"background-color:#e2efd9;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u57fa\u7840\u8bed\u6cd5\u3001\u4e8b\u52a1\u3001\u7d22\u5f15\u3001JOIN \u4f18\u5316<\/span><\/p>\n<\/td>\n<td style=\"background-color:#e2efd9;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6267\u884c\u8ba1\u5212\u3001\u9501\u673a\u5236\u3001\u5206\u5e93\u5206\u8868<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6570\u636e\u5206\u6790<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u805a\u5408\u3001\u7a97\u53e3\u51fd\u6570\u3001CTE\u3001\u4e1a\u52a1\u5efa\u6a21<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6f0f\u6597\/\u7559\u5b58\u5206\u6790\u3001\u591a\u7ef4\u6c47\u603b\u3001\u6027\u80fd\u4f18\u5316<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#e2efd9;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6570\u4ed3\u5f00\u53d1<\/span><\/p>\n<\/td>\n<td style=\"background-color:#e2efd9;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6570\u4ed3\u5efa\u6a21\u3001ETL \u903b\u8f91\u3001\u589e\u91cf\u8ba1\u7b97<\/span><\/p>\n<\/td>\n<td style=\"background-color:#e2efd9;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5206\u5c42\u8bbe\u8ba1\u3001\u6570\u636e\u8d28\u91cf\u3001\u6027\u80fd\u6cbb\u7406<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5206\u6790\u5de5\u7a0b\u5e08<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5168\u6808 SQL &#043; \u5de5\u7a0b\u5316\u5de5\u5177<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">dbt \u9879\u76ee\u3001\u6570\u636e\u6cbb\u7406\u3001CI\/CD<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">0.3 \u77e5\u8bc6\u5730\u56fe&#xff08;\u5b8c\u6574\u7248&#xff09;<\/span><\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:#f5f6f7;border-color:#dee0e3;width:414.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u57fa\u7840\u5c42&#xff1a;<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5173\u7cfb\u601d\u7ef4 \u2192 \u8fc7\u6ee4\u6392\u5e8f \u2192 \u805a\u5408\u5206\u7ec4 \u2192 \u591a\u8868 JOIN \u2192 NULL \u5904\u7406 \u2192 \u96c6\u5408\u8fd0\u7b97 \u00a0\u00a0\u00a0 \u2193 \u4e2d\u7ea7\u5c42&#xff1a;<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5b50\u67e5\u8be2 \u2192 CTE \u5206\u5c42 \u2192 \u6761\u4ef6\u805a\u5408 \u2192 \u7a97\u53e3\u51fd\u6570 \u2192 \u89c6\u56fe\/\u4e8b\u52a1\/\u7d22\u5f15\u76f4\u89c9 \u00a0\u00a0\u00a0 \u2193 \u9ad8\u7ea7\u5c42&#xff1a;<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6267\u884c\u8ba1\u5212\u4e0e\u4f18\u5316 \u2192 \u6570\u636e\u5efa\u6a21(OLTP\/OLAP) \u2192 \u534a\u7ed3\u6784\u5316\/JSON \u2192 \u65b9\u8a00\u9002\u914d \u2192 \u9ad8\u7ea7\u7279\u6027 \u00a0\u00a0\u00a0 \u2193 \u5de5\u7a0b\u5c42&#xff1a;<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6570\u636e\u8d28\u91cf\u6d4b\u8bd5 \u2192 \u589e\u91cf\u4e0e\u5e42\u7b49\u8bbe\u8ba1 \u2192 dbt \u5de5\u5177\u94fe \u2192 \u6210\u672c\u6cbb\u7406 \u2192 \u5b89\u5168\u4e0e\u5408\u89c4<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#7030a0\">\u7b2c 01 \u7ae0 \u00b7 \u5fc3\u667a\u6a21\u578b<\/span><\/h2>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">1.1 SQL \u7684\u58f0\u660e\u5f0f\u672c\u8d28<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">SQL \u662f\u58f0\u660e\u5f0f\u8bed\u8a00&#xff1a;\u4f60\u63cf\u8ff0\u300c\u60f3\u8981\u4ec0\u4e48\u7ed3\u679c\u96c6\u5408\u300d&#xff0c;\u6570\u636e\u5e93\u4f18\u5316\u5668\u51b3\u5b9a\u300c\u600e\u4e48\u7b97\u3001\u7528\u4ec0\u4e48\u8def\u5f84\u7b97\u300d\u3002<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u547d\u4ee4\u5f0f\u601d\u7ef4&#xff08;\u7a0b\u5e8f\u5faa\u73af&#xff09;&#xff1a;\u5148\u53d6\u7528\u6237\u5217\u8868 \u2192 \u5faa\u73af\u6bcf\u4e2a\u7528\u6237\u67e5\u8ba2\u5355 \u2192 \u7d2f\u52a0\u91d1\u989d \u2192 \u8fc7\u6ee4\u7ed3\u679c<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">SQL \u601d\u7ef4&#xff1a;\u58f0\u660e\u300c\u6309\u7528\u6237\u7ef4\u5ea6\u805a\u5408\u8ba2\u5355\u91d1\u989d&#xff0c;\u4fdd\u7559\u91d1\u989d\u5927\u4e8e 1000 \u7684\u7528\u6237\u300d<\/span><\/li>\n<\/ul>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\"><span style=\"color:#646a73\">\u65b0\u624b\u5e38\u72af\u9519\u8bef&#xff1a;\u7528\u5faa\u73af\u903b\u8f91\u7ffb\u8bd1<\/span><span style=\"color:#646a73\"> SQL<\/span><span style=\"color:#646a73\">&#xff0c;\u5bfc\u81f4\u5199\u51fa\u5927\u91cf\u76f8\u5173\u5b50\u67e5\u8be2\u3001\u6e38\u6807&#xff0c;\u6027\u80fd\u6781\u5dee\u4e14\u6613\u51fa\u9519\u3002<\/span><\/span><\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">1.2 \u7ed3\u679c\u96c6\u601d\u7ef4\u4e09\u95ee&#xff08;\u5199 SQL \u524d\u5fc5\u8fc7&#xff09;<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5199\u4efb\u4f55\u67e5\u8be2\u524d&#xff0c;\u5148\u95ee\u81ea\u5df1\u4e09\u4e2a\u95ee\u9898&#xff0c;\u80fd\u907f\u514d 80% \u7684\u903b\u8f91\u9519\u8bef&#xff1a;<\/span><\/p>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4e00\u884c\u4ee3\u8868\u4ec0\u4e48&#xff1f;&#xff08;\u7c92\u5ea6 Grain&#xff09;&#xff1a;\u662f\u4e00\u4e2a\u7528\u6237&#xff1f;\u4e00\u7b14\u8ba2\u5355&#xff1f;\u4e00\u4e2a\u7528\u6237\u7684\u4e00\u5929&#xff1f;\u7c92\u5ea6\u6a21\u7cca\u5fc5\u7136\u5bfc\u81f4\u805a\u5408\u9519\u8bef\u3002<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">JOIN \u540e\u884c\u6570\u4f1a\u53d8\u591a\u8fd8\u662f\u53d8\u5c11&#xff1f;&#xff1a;\u4e00\u5bf9\u591a JOIN \u4f1a\u81a8\u80c0\u884c\u6570&#xff0c;\u591a\u5bf9\u4e00 JOIN \u884c\u6570\u4e0d\u53d8&#xff0c;\u591a\u5bf9\u591a JOIN \u4f1a\u7b1b\u5361\u5c14\u5f0f\u81a8\u80c0\u3002<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">NULL \u548c\u91cd\u590d\u952e\u4f1a\u600e\u4e48\u7834\u574f\u7ed3\u8bba&#xff1f;&#xff1a;\u7a7a\u503c\u4f1a\u88ab\u805a\u5408\u51fd\u6570\u5ffd\u7565\u3001\u4f1a\u5bfc\u81f4 NOT IN \u7ed3\u679c\u4e3a\u7a7a\u3001\u4f1a\u5f71\u54cd\u6392\u5e8f\u4e0e\u7b49\u503c\u5224\u65ad\u3002<\/span><\/li>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">1.3 \u903b\u8f91\u6267\u884c\u987a\u5e8f&#xff08;\u5fc5\u8bb0&#xff09;<\/span><\/h3>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u4e66\u5199\u987a\u5e8f<\/span><\/h4>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:#f5f6f7;border-color:#dee0e3;width:414.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">SELECT <\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u2192 DISTINCT<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u2192 FROM<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u2192 JOIN<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u2192 WHERE<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u2192 GROUP BY <\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u2192 HAVING <\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u2192 ORDER BY <\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u2192 LIMIT\/OFFSET<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u5f15\u64ce\u903b\u8f91\u6267\u884c\u987a\u5e8f&#xff08;\u4ece\u5148\u5230\u540e&#xff09;<\/span><\/h4>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">FROM \/ JOIN<\/span>&#xff1a;\u786e\u5b9a\u6570\u636e\u6e90&#xff0c;\u751f\u6210\u7b1b\u5361\u5c14\u79ef\u540e\u6309 ON \u6761\u4ef6\u8fc7\u6ee4&#xff0c;\u5f97\u5230\u521d\u59cb\u7ed3\u679c\u96c6<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">WHERE<\/span>&#xff1a;\u5bf9\u884c\u7ea7\u6570\u636e\u8fc7\u6ee4&#xff0c;\u6b64\u65f6\u8fd8\u6ca1\u5206\u7ec4\u3001\u6ca1\u8ba1\u7b97 SELECT \u522b\u540d&#xff0c;\u56e0\u6b64 WHERE \u4e2d\u4e0d\u80fd\u7528 SELECT \u522b\u540d<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">GROUP BY<\/span>&#xff1a;\u6309\u5206\u7ec4\u952e\u584c\u7f29\u884c&#xff0c;\u6bcf\u7ec4\u53d8\u6210\u4e00\u884c<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">HAVING<\/span>&#xff1a;\u5bf9\u5206\u7ec4\u540e\u7684\u805a\u5408\u7ed3\u679c\u8fc7\u6ee4&#xff0c;\u53ef\u5f15\u7528\u805a\u5408\u51fd\u6570<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">SELECT<\/span>&#xff1a;\u8ba1\u7b97\u8f93\u51fa\u5217\u3001\u8868\u8fbe\u5f0f\u3001\u7a97\u53e3\u51fd\u6570<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">DISTINCT<\/span>&#xff1a;\u5bf9 SELECT \u7ed3\u679c\u53bb\u91cd<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">ORDER BY<\/span>&#xff1a;\u6392\u5e8f&#xff0c;\u6b64\u65f6\u53ef\u4f7f\u7528 SELECT \u522b\u540d<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">LIMIT \/ OFFSET<\/span>&#xff1a;\u622a\u53d6\u6700\u7ec8\u7ed3\u679c<\/span><\/li>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u7ecf\u5178\u95ee\u9898\u89e3\u7b54<\/span><\/h4>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4e3a\u4ec0\u4e48 WHERE \u4e0d\u80fd\u7528 SELECT \u522b\u540d&#xff1f;\u56e0\u4e3a WHERE \u6267\u884c\u5728 SELECT \u4e4b\u524d\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4e3a\u4ec0\u4e48\u805a\u5408\u8fc7\u6ee4\u8981\u7528 HAVING&#xff1f;\u56e0\u4e3a WHERE \u6267\u884c\u5728 GROUP BY \u4e4b\u524d&#xff0c;\u8fd8\u6ca1\u6709\u805a\u5408\u7ed3\u679c\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4e3a\u4ec0\u4e48\u7a97\u53e3\u51fd\u6570\u4e0d\u80fd\u5199\u5728 WHERE \u91cc&#xff1f;\u56e0\u4e3a\u7a97\u53e3\u51fd\u6570\u5728 SELECT \u9636\u6bb5\u8ba1\u7b97&#xff0c;WHERE \u6267\u884c\u65f6\u8fd8\u672a\u8ba1\u7b97\u3002<\/span><\/li>\n<\/ul>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">1.4 OLTP vs OLAP vs HTAP<\/span><\/h3>\n<table cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:white;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7ef4\u5ea6<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">OLTP&#xff08;\u4e1a\u52a1\u5e93&#xff09;<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">OLAP&#xff08;\u5206\u6790\/\u6570\u4ed3&#xff09;<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">HTAP&#xff08;\u6df7\u5408\u8d1f\u8f7d&#xff09;<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#deeaf6;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5178\u578b\u64cd\u4f5c<\/span><\/p>\n<\/td>\n<td style=\"background-color:#deeaf6;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u70b9\u67e5\u3001\u5199\u5165\u3001\u4e8b\u52a1<\/span><\/p>\n<\/td>\n<td style=\"background-color:#deeaf6;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5168\u8868\u626b\u63cf\u3001\u805a\u5408\u3001\u5bbd\u8868\u5173\u8054<\/span><\/p>\n<\/td>\n<td style=\"background-color:#deeaf6;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u540c\u65f6\u652f\u6301\u4e1a\u52a1\u5199\u5165\u4e0e\u5b9e\u65f6\u5206\u6790<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6a21\u578b\u503e\u5411<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u89c4\u8303\u5316&#xff08;\u4e09\u8303\u5f0f&#xff09;&#xff0c;\u51cf\u5c11\u5197\u4f59<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u661f\u578b\/\u96ea\u82b1\u6a21\u578b\u3001\u5bbd\u8868\u3001\u53cd\u8303\u5f0f<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u517c\u987e\u89c4\u8303\u5316\u4e0e\u5206\u6790\u6027\u80fd<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#deeaf6;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6027\u80fd\u5173\u6ce8\u70b9<\/span><\/p>\n<\/td>\n<td style=\"background-color:#deeaf6;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7d22\u5f15\u547d\u4e2d\u7387\u3001\u9501\u3001\u9694\u79bb\u7ea7\u522b<\/span><\/p>\n<\/td>\n<td style=\"background-color:#deeaf6;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u626b\u63cf\u6570\u636e\u91cf\u3001\u5206\u533a\u3001\u5e76\u884c\u5ea6<\/span><\/p>\n<\/td>\n<td style=\"background-color:#deeaf6;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u8bfb\u5199\u9694\u79bb\u3001\u8d44\u6e90\u9694\u79bb\u3001\u5217\u5f0f\u5b58\u50a8<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6570\u636e\u89c4\u6a21<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u884c\u7ea7&#xff0c;GB-TB \u7ea7<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5168\u91cf\u5386\u53f2&#xff0c;TB-PB \u7ea7<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u53ef\u6a2a\u5411\u6269\u5c55&#xff0c;PB \u7ea7<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#deeaf6;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4ee3\u8868\u5f15\u64ce<\/span><\/p>\n<\/td>\n<td style=\"background-color:#deeaf6;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">PostgreSQL\u3001MySQL<\/span><\/p>\n<\/td>\n<td style=\"background-color:#deeaf6;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">DuckDB\u3001Snowflake\u3001ClickHouse<\/span><\/p>\n<\/td>\n<td style=\"background-color:#deeaf6;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">TiDB\u3001OceanBase\u3001PolarDB<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#7030a0\">\u7b2c 02 \u7ae0 \u00b7 \u5173\u7cfb\u6a21\u578b\u4e0e\u67e5\u8be2\u9aa8\u67b6&#xff08;\u57fa\u7840&#xff09;<\/span><\/h2>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">2.1 \u5173\u7cfb\u6a21\u578b\u6838\u5fc3\u6982\u5ff5<\/span><\/h3>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u8868&#xff08;\u5173\u7cfb&#xff09;&#xff1a;\u4e8c\u7ef4\u7ed3\u6784&#xff0c;\u7531\u884c\u548c\u5217\u7ec4\u6210<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u884c&#xff08;\u5143\u7ec4&#xff09;&#xff1a;\u4e00\u6761\u5b8c\u6574\u7684\u5b9e\u4f53\u8bb0\u5f55<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5217&#xff08;\u5c5e\u6027&#xff09;&#xff1a;\u5b9e\u4f53\u7684\u4e00\u4e2a\u7279\u5f81&#xff0c;\u6709\u4e25\u683c\u7684\u6570\u636e\u7c7b\u578b<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4e3b\u952e&#xff08;PK&#xff09;&#xff1a;\u552f\u4e00\u6807\u8bc6\u4e00\u884c&#xff0c;\u975e\u7a7a\u4e14\u552f\u4e00<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5916\u952e&#xff08;FK&#xff09;&#xff1a;\u5f15\u7528\u53e6\u4e00\u8868\u7684\u4e3b\u952e&#xff0c;\u8868\u8fbe\u5b9e\u4f53\u95f4\u5173\u8054\u5173\u7cfb<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u7ea6\u675f&#xff1a;NOT NULL\u3001UNIQUE\u3001CHECK\u3001FOREIGN KEY\u3001DEFAULT<\/span><\/li>\n<\/ul>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5e38\u89c1\u5173\u7cfb\u4e0e\u5b9e\u73b0&#xff1a;<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4e00\u5bf9\u4e00&#xff1a;\u5171\u4eab\u4e3b\u952e&#xff0c;\u6216\u4e00\u65b9\u6301\u6709\u552f\u4e00\u5916\u952e&#xff08;UNIQUE &#043; FK&#xff09;<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4e00\u5bf9\u591a&#xff1a;\u591a\u65b9\u6301\u6709\u5916\u952e&#xff08;\u6700\u5e38\u89c1&#xff0c;\u5982\u7528\u6237-\u8ba2\u5355&#xff09;<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u591a\u5bf9\u591a&#xff1a;\u901a\u8fc7\u4e2d\u95f4\u8868\u62c6\u89e3\u4e3a\u4e24\u4e2a\u4e00\u5bf9\u591a&#xff08;\u5982\u5b66\u751f-\u8bfe\u7a0b-\u9009\u8bfe\u8868&#xff09;<\/span><\/li>\n<\/ul>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">2.2 \u89c4\u8303\u5316\u4e0e\u53cd\u8303\u5f0f<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4e09\u8303\u5f0f\u6838\u5fc3\u76ee\u6807&#xff1a;\u51cf\u5c11\u6570\u636e\u5197\u4f59&#xff0c;\u907f\u514d\u66f4\u65b0\u5f02\u5e38\u3001\u63d2\u5165\u5f02\u5e38\u3001\u5220\u9664\u5f02\u5e38\u3002<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">1NF&#xff1a;\u5217\u4e0d\u53ef\u518d\u5206<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">2NF&#xff1a;\u6d88\u9664\u90e8\u5206\u4f9d\u8d56&#xff0c;\u975e\u4e3b\u952e\u5217\u5b8c\u5168\u4f9d\u8d56\u4e3b\u952e<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">3NF&#xff1a;\u6d88\u9664\u4f20\u9012\u4f9d\u8d56&#xff0c;\u975e\u4e3b\u952e\u5217\u4e0d\u4f9d\u8d56\u5176\u4ed6\u975e\u4e3b\u952e\u5217<\/span><\/li>\n<\/ul>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5206\u6790\u573a\u666f\u7684\u53cd\u8303\u5f0f\u8bbe\u8ba1&#xff1a; \u6570\u4ed3\u4e0e\u5bbd\u8868\u573a\u666f\u5e38\u6545\u610f\u5197\u4f59\u7ef4\u5ea6\u4fe1\u606f&#xff08;\u5982\u628a\u7528\u6237\u57ce\u5e02\u3001\u7b49\u7ea7\u5197\u4f59\u5230\u8ba2\u5355\u8868&#xff09;&#xff0c;\u7528\u7a7a\u95f4\u6362\u67e5\u8be2\u6548\u7387&#xff0c;\u51cf\u5c11 JOIN \u6b21\u6570\u3002<\/span><\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">2.3 \u67e5\u8be2\u57fa\u7840\u9aa8\u67b6<\/span><\/h3>\n<p>SELECT<br \/>\n\u00a0 column1,<br \/>\n\u00a0 column2 * 0.8 AS discount_price,\u00a0 &#8212; \u8868\u8fbe\u5f0f\u4e0e\u522b\u540d<br \/>\n\u00a0 CONCAT(first_name, &#039; &#039;, last_name) AS full_name<br \/>\nFROM schema.table_name<br \/>\nWHERE status &#061; &#039;active&#039;<br \/>\n\u00a0 AND created_at &gt;&#061; &#039;2026-01-01&#039;<br \/>\nORDER BY created_at DESC<br \/>\nLIMIT 100; <\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u8981\u70b9\u8865\u5145&#xff1a;<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u751f\u4ea7\u73af\u5883\u7981\u6b62 <span style=\"background-color:#eff0f1\">SELECT *<\/span>&#xff1a;\u62c9\u53d6\u65e0\u5173\u5217\u589e\u52a0 IO&#xff0c;\u5927\u8868\u5bbd\u8868\u4f1a\u4e25\u91cd\u62d6\u6162\u6027\u80fd&#xff0c;\u4e14\u8868\u7ed3\u6784\u53d8\u66f4\u65f6\u6613\u51fa\u95ee\u9898\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">DISTINCT<\/span> \u6210\u672c\u5f88\u9ad8&#xff1a;\u5b83\u9700\u8981\u6392\u5e8f\u6216\u54c8\u5e0c\u53bb\u91cd&#xff0c;\u5927\u8868\u4e0a\u614e\u7528&#xff1b;\u5148\u60f3\u6e05\u695a\u91cd\u590d\u884c\u7684\u6765\u6e90&#xff0c;\u4f18\u5148\u901a\u8fc7\u8fc7\u6ee4\u6216 JOIN \u4f18\u5316\u6d88\u9664\u91cd\u590d\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u522b\u540d\u53ef\u8bfb\u6027\u4f18\u5148&#xff1a;\u4e1a\u52a1\u542b\u4e49\u660e\u786e&#xff0c;\u907f\u514d\u65e0\u610f\u4e49\u7684 a\u3001b\u3001c \u522b\u540d\u3002<\/span><\/li>\n<\/ul>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">2.4 \u8fc7\u6ee4\u6761\u4ef6&#xff08;WHERE&#xff09;<\/span><\/h3>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u5e38\u7528\u8c13\u8bcd<\/span><\/h4>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6bd4\u8f83&#xff1a;<span style=\"background-color:#eff0f1\">&#061;<\/span>\u3001<span style=\"background-color:#eff0f1\">&lt;&gt;<\/span>\/<span style=\"background-color:#eff0f1\">!&#061;<\/span>\u3001<span style=\"background-color:#eff0f1\">&lt;<\/span>\u3001<span style=\"background-color:#eff0f1\">&gt;<\/span>\u3001<span style=\"background-color:#eff0f1\">&lt;&#061;<\/span>\u3001<span style=\"background-color:#eff0f1\">&gt;&#061;<\/span><\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u903b\u8f91&#xff1a;<span style=\"background-color:#eff0f1\">AND<\/span>\u3001<span style=\"background-color:#eff0f1\">OR<\/span>\u3001<span style=\"background-color:#eff0f1\">NOT<\/span>&#xff08;\u6ce8\u610f\u4f18\u5148\u7ea7&#xff1a;NOT &gt; AND &gt; OR&#xff0c;\u590d\u6742\u6761\u4ef6\u52a1\u5fc5\u52a0\u62ec\u53f7&#xff09;<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u96c6\u5408&#xff1a;<span style=\"background-color:#eff0f1\">IN (&#8230;)<\/span>\u3001<span style=\"background-color:#eff0f1\">BETWEEN &#8230; AND &#8230;<\/span>&#xff08;\u95ed\u533a\u95f4&#xff09;<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6a21\u7cca\u5339\u914d&#xff1a;<span style=\"background-color:#eff0f1\">LIKE<\/span>&#xff08;<span style=\"background-color:#eff0f1\">%<\/span>\u5339\u914d\u4efb\u610f\u5b57\u7b26&#xff0c;<span style=\"background-color:#eff0f1\">_<\/span>\u5339\u914d\u5355\u4e2a\u5b57\u7b26&#xff09;&#xff1b;PostgreSQL \u652f\u6301 <span style=\"background-color:#eff0f1\">ILIKE<\/span> \u5ffd\u7565\u5927\u5c0f\u5199<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u7a7a\u503c\u5224\u65ad&#xff1a;\u53ea\u80fd\u7528 <span style=\"background-color:#eff0f1\">IS NULL<\/span> \/ <span style=\"background-color:#eff0f1\">IS NOT NULL<\/span>&#xff0c;<span style=\"background-color:#eff0f1\">&#061; NULL<\/span> \u6c38\u8fdc\u4e0d\u6210\u7acb<\/span><\/li>\n<\/ul>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u65e5\u671f\u8fc7\u6ee4\u9ec4\u91d1\u539f\u5219&#xff1a;\u5de6\u95ed\u53f3\u5f00<\/span><\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5c3d\u91cf\u4f7f\u7528 <span style=\"background-color:#eff0f1\">&gt;&#061; <\/span><span style=\"background-color:#eff0f1\">\u8d77\u59cb<\/span> \u548c <span style=\"background-color:#eff0f1\">&lt; <\/span><span style=\"background-color:#eff0f1\">\u7ed3\u675f&#043;1<\/span> \u7684\u5199\u6cd5&#xff0c;\u907f\u514d <span style=\"background-color:#eff0f1\">DATE()<\/span> \u51fd\u6570\u5305\u88f9\u7d22\u5f15\u5217\u5bfc\u81f4\u7d22\u5f15\u5931\u6548\u3002<\/span><\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:#f5f6f7;border-color:#dee0e3;width:414.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">&#8212; \u63a8\u8350&#xff1a;\u5de6\u95ed\u53f3\u5f00&#xff0c;\u53ef\u547d\u4e2d created_at \u7d22\u5f15<\/span> \u00a0<\/p>\n<p> WHERE created_at &gt;&#061; &#039;2026-01-01&#039;<br \/>\n\u00a0 AND created_at &lt; &#039;2026-02-01&#039; <\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">&#8212; \u4e0d\u63a8\u8350&#xff1a;\u51fd\u6570\u5305\u88f9\u5217&#xff0c;\u7d22\u5f15\u5931\u6548<\/span><\/p>\n<p> WHERE DATE(created_at) BETWEEN &#039;2026-01-01&#039; AND &#039;2026-01-31&#039; <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">2.5 NULL \u4e0e\u4e09\u503c\u903b\u8f91&#xff08;\u57fa\u7840\u7b2c\u4e00\u5927\u5751&#xff09;<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">SQL \u6761\u4ef6\u7ed3\u679c\u6709\u4e09\u79cd&#xff1a;<span style=\"background-color:#eff0f1\">TRUE<\/span> \/ <span style=\"background-color:#eff0f1\">FALSE<\/span> \/ <span style=\"background-color:#eff0f1\">UNKNOWN<\/span>&#xff0c;WHERE \u53ea\u4fdd\u7559 <span style=\"background-color:#eff0f1\">TRUE<\/span> \u7684\u884c\u3002<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6838\u5fc3\u89c4\u5219<\/span><\/p>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4efb\u4f55\u503c\u4e0e NULL \u6bd4\u8f83\u90fd\u662f UNKNOWN&#xff1a;<span style=\"background-color:#eff0f1\">NULL &#061; NULL<\/span> \u2192 \u672a\u77e5&#xff0c;<span style=\"background-color:#eff0f1\">1 !&#061; NULL<\/span> \u2192 \u672a\u77e5&#xff0c;<span style=\"background-color:#eff0f1\">NULL &gt; 0<\/span> \u2192 \u672a\u77e5<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u805a\u5408\u51fd\u6570\u9ed8\u8ba4\u5ffd\u7565 NULL&#xff1a;<span style=\"background-color:#eff0f1\">SUM(col)<\/span> \u4e0d\u8ba1\u7a7a\u503c\u884c&#xff1b;<span style=\"background-color:#eff0f1\">COUNT(*)<\/span> \u8ba1\u6240\u6709\u884c&#xff0c;<span style=\"background-color:#eff0f1\">COUNT(col)<\/span> \u4e0d\u8ba1\u8be5\u5217\u4e3a\u7a7a\u7684\u884c<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">NOT IN \u5b50\u67e5\u8be2\u542b NULL \u65f6&#xff0c;\u7ed3\u679c\u5168\u4e3a\u7a7a&#xff1a;\u7ecf\u5178\u5751&#xff0c;\u53cd\u8fde\u63a5\u4f18\u5148\u7528 <span style=\"background-color:#eff0f1\">NOT EXISTS<\/span> \u6216 <span style=\"background-color:#eff0f1\">LEFT JOIN &#8230; IS NULL<\/span><\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6392\u5e8f\u65f6 NULL \u4f4d\u7f6e&#xff1a;\u4e0d\u540c\u5f15\u64ce\u9ed8\u8ba4\u4e0d\u540c&#xff0c;PostgreSQL \u9ed8\u8ba4\u4e3a NULLS LAST&#xff0c;\u53ef\u663e\u5f0f\u6307\u5b9a <span style=\"background-color:#eff0f1\">NULLS FIRST\/LAST<\/span><\/span><\/li>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">2.6 \u6392\u5e8f\u4e0e\u622a\u53d6<\/span><\/h3>\n<p>ORDER BY revenue DESC NULLS LAST, user_id ASC<br \/>\nLIMIT 10 OFFSET 20;\u00a0 &#8212; \u8df3\u8fc7\u524d20\u6761&#xff0c;\u53d610\u6761 <\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u65e0\u7a33\u5b9a ORDER BY \u65f6&#xff0c;LIMIT \u7ed3\u679c\u4e0d\u786e\u5b9a&#xff0c;\u5206\u9875\u53ef\u80fd\u51fa\u73b0\u91cd\u590d\u6216\u6f0f\u6570\u636e\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5927\u504f\u79fb\u91cf OFFSET \u6027\u80fd\u5dee&#xff1a;OFFSET 100000 \u9700\u8981\u5148\u626b\u63cf 100000 \u884c\u518d\u4e22\u5f03&#xff0c;\u6df1\u5206\u9875\u63a8\u8350\u7528\u300c\u6e38\u6807\u5206\u9875\u300d&#xff08;\u57fa\u4e8e\u4e0a\u4e00\u9875\u6700\u540e\u4e00\u4e2a ID \u8fc7\u6ee4&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">2.7 \u5e38\u7528\u6570\u636e\u7c7b\u578b\u4e0e\u8f6c\u6362<\/span><\/h3>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5b57\u7b26\u4e32&#xff1a;\u62fc\u63a5\u3001\u5927\u5c0f\u5199\u8f6c\u6362\u3001\u622a\u53d6\u3001\u66ff\u6362\u3001\u6b63\u5219\u5339\u914d<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6570\u503c&#xff1a;\u56db\u5219\u8fd0\u7b97\u3001\u53d6\u6574&#xff08;ROUND\/FLOOR\/CEIL&#xff09;\u3001\u7edd\u5bf9\u503c\u3001\u767e\u5206\u6bd4\u8ba1\u7b97<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u65e5\u671f\u65f6\u95f4&#xff1a;\u52a0\u51cf\u95f4\u9694\u3001\u622a\u65ad&#xff08;DATE_TRUNC&#xff09;\u3001\u65f6\u533a\u8f6c\u6362&#xff08;\u6ce8\u610f TIMESTAMP WITH TIME ZONE&#xff09;<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u7c7b\u578b\u8f6c\u6362&#xff1a;\u6807\u51c6\u5199\u6cd5 <span style=\"background-color:#eff0f1\">CAST(x AS type)<\/span>&#xff0c;PostgreSQL \u652f\u6301\u7b80\u5199 <span style=\"background-color:#eff0f1\">x::type<\/span><\/span><\/li>\n<\/ul>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\"><span style=\"color:#646a73\">\u9690\u5f0f\u8f6c\u6362\u662f\u6027\u80fd\u4e0e\u6b63\u786e\u6027\u7684\u9690\u5f62\u6740\u624b&#xff1a;\u5b57\u7b26\u4e32\u4e0e\u6570\u5b57\u6bd4\u8f83\u3001\u4e0d\u540c\u65f6\u95f4\u7c7b\u578b\u6bd4\u8f83&#xff0c;\u90fd\u53ef\u80fd\u5bfc\u81f4\u7d22\u5f15\u5931\u6548\u6216\u7ed3\u679c\u9519\u8bef\u3002<\/span><\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n<h2 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#7030a0\">\u7b2c 03 \u7ae0 \u00b7 \u8fc7\u6ee4\u805a\u5408\u4e0e JOIN&#xff08;\u57fa\u7840&#xff09;<\/span><\/h2>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">3.1 \u805a\u5408\u51fd\u6570<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5de5\u4f5c\u4e2d\u6700\u5e38\u7528\u7684\u4e94\u5927\u805a\u5408&#xff1a;<span style=\"background-color:#eff0f1\">COUNT<\/span> \/ <span style=\"background-color:#eff0f1\">SUM<\/span> \/ <span style=\"background-color:#eff0f1\">AVG<\/span> \/ <span style=\"background-color:#eff0f1\">MIN<\/span> \/ <span style=\"background-color:#eff0f1\">MAX<\/span><\/span><\/p>\n<p>SELECT<br \/>\n\u00a0 user_id,<br \/>\n\u00a0 COUNT(*) AS order_cnt,<br \/>\n\u00a0 SUM(amount) AS total_revenue,<br \/>\n\u00a0 AVG(amount) AS avg_order_amount,<br \/>\n\u00a0 MIN(amount) AS min_amount,<br \/>\n\u00a0 MAX(amount) AS max_amount<br \/>\nFROM orders<br \/>\nWHERE status &#061; &#039;paid&#039;<br \/>\nGROUP BY user_id; <\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u89c4\u5219<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">SELECT \u4e2d\u7684\u975e\u805a\u5408\u5217&#xff0c;\u5fc5\u987b\u51fa\u73b0\u5728 GROUP BY \u4e2d&#xff08;\u4e25\u683c SQL \u6a21\u5f0f\u4e0b&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">GROUP BY \u7684\u5217\u51b3\u5b9a\u4e86\u300c\u8f93\u51fa\u4e00\u884c\u4ee3\u8868\u4ec0\u4e48\u300d&#xff0c;\u5373\u6700\u7ec8\u7ed3\u679c\u7684\u7c92\u5ea6\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u53ef\u6309\u591a\u5217\u5206\u7ec4&#xff1a;<span style=\"background-color:#eff0f1\">GROUP BY user_id, date<\/span> \u4ee3\u8868\u300c\u6bcf\u4e2a\u7528\u6237\u6bcf\u5929\u4e00\u884c\u300d\u3002<\/span><\/li>\n<\/ul>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">3.2 HAVING&#xff1a;\u5206\u7ec4\u540e\u8fc7\u6ee4<\/span><\/h3>\n<p>SELECT user_id, SUM(amount) AS revenue<br \/>\nFROM orders<br \/>\nGROUP BY user_id<br \/>\nHAVING SUM(amount) &gt; 1000; <\/p>\n<table cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5b50\u53e5<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u8fc7\u6ee4\u65f6\u673a<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u53ef\u5f15\u7528\u7684\u5185\u5bb9<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#fff2cc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">WHERE<\/span><\/p>\n<\/td>\n<td style=\"background-color:#fff2cc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5206\u7ec4\u524d&#xff0c;\u884c\u7ea7<\/span><\/p>\n<\/td>\n<td style=\"background-color:#fff2cc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u539f\u59cb\u5217&#xff0c;\u4e0d\u80fd\u7528\u805a\u5408\u51fd\u6570<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">HAVING<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5206\u7ec4\u540e&#xff0c;\u7ec4\u7ea7<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u805a\u5408\u51fd\u6570\u3001GROUP BY \u5217<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\"><span style=\"color:#646a73\">\u4f18\u5316\u5efa\u8bae&#xff1a;\u80fd\u7528<\/span><span style=\"color:#646a73\"> WHERE <\/span><span style=\"color:#646a73\">\u63d0\u524d\u8fc7\u6ee4\u7684&#xff0c;\u4e0d\u8981\u653e\u5230<\/span><span style=\"color:#646a73\"> HAVING<\/span><span style=\"color:#646a73\">\u3002\u5148\u7f29\u5c0f\u6570\u636e\u8303\u56f4\u518d\u805a\u5408&#xff0c;\u6027\u80fd\u66f4\u597d\u3002<\/span><\/span><\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">3.3 JOIN&#xff1a;\u57fa\u7840\u5206\u6c34\u5cad<\/span><\/h3>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">3.3.1 JOIN \u7c7b\u578b\u4e0e\u884c\u6570\u76f4\u89c9<\/span><\/h4>\n<table cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7c7b\u578b<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u542b\u4e49<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u884c\u6570\u53d8\u5316\u76f4\u89c9<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#ededed;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">INNER JOIN<\/span><\/p>\n<\/td>\n<td style=\"background-color:#ededed;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u53ea\u4fdd\u7559\u4e24\u8fb9\u90fd\u5339\u914d\u7684\u884c<\/span><\/p>\n<\/td>\n<td style=\"background-color:#ededed;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u2264 \u4e24\u4fa7\u539f\u59cb\u884c\u6570<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">LEFT JOIN<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4fdd\u7559\u5de6\u8868\u5168\u90e8&#xff0c;\u53f3\u8868\u4e0d\u5339\u914d\u5219\u8865 NULL<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u2265 \u5de6\u8868\u884c\u6570&#xff08;\u4e00\u5bf9\u591a\u4f1a\u81a8\u80c0&#xff09;<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#ededed;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">RIGHT JOIN<\/span><\/p>\n<\/td>\n<td style=\"background-color:#ededed;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4fdd\u7559\u53f3\u8868\u5168\u90e8&#xff0c;\u5de6\u8868\u4e0d\u5339\u914d\u5219\u8865 NULL<\/span><\/p>\n<\/td>\n<td style=\"background-color:#ededed;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u53ef\u7528 LEFT JOIN \u6539\u5199&#xff0c;\u5c11\u7528<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">FULL OUTER JOIN<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4e24\u4fa7\u672a\u5339\u914d\u7684\u90fd\u4fdd\u7559&#xff0c;\u5bf9\u65b9\u8865 NULL<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u2265 \u4e24\u4fa7\u4e2d\u8f83\u5927\u7684\u884c\u6570<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#ededed;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">CROSS JOIN<\/span><\/p>\n<\/td>\n<td style=\"background-color:#ededed;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7b1b\u5361\u5c14\u79ef&#xff0c;\u5de6\u8868\u6bcf\u4e00\u884c\u5339\u914d\u53f3\u8868\u6bcf\u4e00\u884c<\/span><\/p>\n<\/td>\n<td style=\"background-color:#ededed;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5de6\u8868\u884c\u6570 \u00d7 \u53f3\u8868\u884c\u6570&#xff0c;\u614e\u7528<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">3.3.2 ON vs WHERE&#xff08;OUTER JOIN \u6838\u5fc3\u5751&#xff09;<\/span><\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5bf9 LEFT JOIN \u800c\u8a00&#xff1a;<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6761\u4ef6\u5199\u5728 ON \u91cc&#xff1a;\u5148\u6309\u6761\u4ef6\u5339\u914d\u53f3\u8868&#xff0c;\u4e0d\u5339\u914d\u7684\u5de6\u8868\u884c\u4ecd\u4fdd\u7559&#xff0c;\u53f3\u8868\u5217\u8865 NULL\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6761\u4ef6\u5199\u5728 WHERE \u91cc&#xff1a;JOIN \u5b8c\u6210\u540e\u518d\u8fc7\u6ee4&#xff0c;\u4f1a\u628a\u53f3\u8868\u4e3a NULL \u7684\u884c\u8fc7\u6ee4\u6389&#xff0c;\u6548\u679c\u63a5\u8fd1 INNER JOIN\u3002<\/span><\/li>\n<\/ul>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:#f5f6f7;border-color:#dee0e3;width:414.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">&#8212; \u7ed3\u679c&#xff1a;\u6240\u6709\u7528\u6237\u90fd\u51fa\u73b0&#xff0c;2026\u5e74\u65e0\u8ba2\u5355\u7684\u7528\u6237\u8ba2\u5355\u5217\u4e3aNULL<\/span> \u00a0<\/p>\n<p> SELECT u.user_id, o.order_id<br \/>\nFROM users u<br \/>\nLEFT JOIN orders o<br \/>\n\u00a0 ON u.user_id &#061; o.user_id<br \/>\n\u00a0 AND o.order_date &gt;&#061; &#039;2026-01-01&#039;; <\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">&#8212; \u7ed3\u679c&#xff1a;\u53ea\u67092026\u5e74\u6709\u8ba2\u5355\u7684\u7528\u6237\u624d\u51fa\u73b0&#xff0c;\u7b49\u4ef7\u4e8eINNER JOIN<\/span><\/p>\n<p> SELECT u.user_id, o.order_id<br \/>\nFROM users u<br \/>\nLEFT JOIN orders o<br \/>\n\u00a0 ON u.user_id &#061; o.user_id<br \/>\nWHERE o.order_date &gt;&#061; &#039;2026-01-01&#039;; <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">3.3.3 \u884c\u6570\u81a8\u80c0\u4e0e\u7c92\u5ea6\u5bf9\u9f50<\/span><\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4e00\u5bf9\u591a JOIN \u4f1a\u590d\u5236\u5de6\u8868\u884c&#xff08;\u5982\u4e00\u4e2a\u7528\u6237 3 \u4e2a\u8ba2\u5355&#xff0c;\u7528\u6237\u5b57\u6bb5\u4f1a\u91cd\u590d 3 \u6b21&#xff09;\u3002<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u9519\u8bef\u505a\u6cd5&#xff1a;JOIN \u660e\u7ec6\u540e\u76f4\u63a5 SUM \u7528\u6237\u7ef4\u5ea6\u7684\u91d1\u989d&#xff0c;\u5bfc\u81f4\u91d1\u989d\u88ab\u653e\u5927 N \u500d\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6b63\u786e\u505a\u6cd5&#xff1a;\u5148\u805a\u5408\u5230\u76f8\u540c\u7c92\u5ea6&#xff0c;\u518d JOIN&#xff1b;\u6216\u5148\u53bb\u91cd\u518d\u5173\u8054\u3002<\/span><\/li>\n<\/ul>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">3.4 \u591a\u8868\u5173\u8054\u7ecf\u5178\u7ec3\u4e60<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u57fa\u4e8e\u7528\u6237\u8868 users\u3001\u8ba2\u5355\u8868 orders\u3001\u8ba2\u5355\u660e\u7ec6\u8868 order_items&#xff1a;<\/span><\/p>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u67d0\u6708\u6210\u4ea4\u989d Top 10 \u7528\u6237&#xff1a;INNER JOIN &#043; \u805a\u5408 &#043; \u6392\u5e8f &#043; LIMIT<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4ece\u672a\u4e0b\u5355\u7684\u5ba2\u6237\u5217\u8868&#xff1a;LEFT JOIN &#043; WHERE \u53f3\u8868\u4e3b\u952e IS NULL<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5f53\u6708\u6d3b\u8dc3\u7528\u6237\u6570&#xff1a;\u6ce8\u610f\u53bb\u91cd&#xff0c;\u7528 COUNT(DISTINCT user_id)&#xff0c;\u907f\u514d\u660e\u7ec6\u884c\u91cd\u590d\u8ba1\u6570<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6bcf\u4e2a\u7528\u6237\u7684\u9996\u5355\u65f6\u95f4\u4e0e\u9996\u5355\u91d1\u989d&#xff1a;\u5206\u7ec4\u53d6\u6700\u5c0f\u503c<\/span><\/li>\n<h2 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#7030a0\">\u7b2c 04 \u7ae0 \u00b7 \u96c6\u5408\u8fd0\u7b97\u4e0e DDL\/DML&#xff08;\u57fa\u7840&#xff09;<\/span><\/h2>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">4.1 \u96c6\u5408\u8fd0\u7b97<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u628a\u4e24\u4e2a\u67e5\u8be2\u7ed3\u679c\u96c6\u5f53\u4f5c\u96c6\u5408\u64cd\u4f5c&#xff0c;\u8981\u6c42\u4e24\u4fa7\u5217\u6570\u4e00\u81f4\u3001\u7c7b\u578b\u517c\u5bb9\u3002<\/span><\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:#f5f6f7;border-color:#dee0e3;width:414.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">&#8212; UNION&#xff1a;\u53bb\u91cd\u5408\u5e76&#xff08;\u6027\u80fd\u5dee&#xff0c;\u9700\u8981\u6392\u5e8f\u53bb\u91cd&#xff09;<\/span> \u00a0<\/p>\n<p> SELECT user_id FROM orders_2025<br \/>\nUNION<br \/>\nSELECT user_id FROM orders_2026; <\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">&#8212; UNION ALL&#xff1a;\u4e0d\u53bb\u91cd\u5408\u5e76&#xff08;\u6027\u80fd\u597d&#xff0c;\u4f18\u5148\u4f7f\u7528&#xff09;<\/span> \u00a0<\/p>\n<p> SELECT user_id FROM orders_2025<br \/>\nUNION ALL<br \/>\nSELECT user_id FROM orders_2026; <\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">&#8212; INTERSECT&#xff1a;\u4ea4\u96c6<\/span> \u00a0<\/p>\n<p> SELECT user_id FROM paid_users<br \/>\nINTERSECT<br \/>\nSELECT user_id FROM active_users; <\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">&#8212; EXCEPT&#xff1a;\u5dee\u96c6&#xff08;A \u6709 B \u6ca1\u6709&#xff09;<\/span><\/p>\n<p> SELECT user_id FROM all_users<br \/>\nEXCEPT<br \/>\nSELECT user_id FROM churned_users; <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u8981\u70b9&#xff1a;<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4f18\u5148\u7528 UNION ALL&#xff0c;\u786e\u5b9a\u9700\u8981\u53bb\u91cd\u65f6\u624d\u7528 UNION\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5217\u540d\u8ddf\u968f\u5de6\u4fa7\u67e5\u8be2&#xff0c;ORDER BY \u53ea\u80fd\u5199\u5728\u6700\u5916\u5c42\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5206\u6790\u573a\u666f\u5e38\u7528 UNION ALL \u62fc\u63a5\u5206\u533a\u8868\u3001\u4e0d\u540c\u6708\u4efd\u7684\u5206\u8868\u3002<\/span><\/li>\n<\/ul>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">4.2 NULL \u5728\u96c6\u5408\u4e2d\u7684\u5751<\/span><\/h3>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">NOT IN (<\/span><span style=\"background-color:#eff0f1\">\u5b50\u67e5\u8be2)<\/span> \u82e5\u5b50\u67e5\u8be2\u7ed3\u679c\u5305\u542b NULL&#xff0c;\u6574\u4e2a\u6761\u4ef6\u7ed3\u679c\u4e3a UNKNOWN&#xff0c;\u67e5\u8be2\u8fd4\u56de\u7a7a\u96c6&#xff0c;\u8fd9\u662f\u7ecf\u5178\u6613\u9519\u70b9\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u53cd\u8fde\u63a5\u573a\u666f\u4f18\u5148\u4f7f\u7528 <span style=\"background-color:#eff0f1\">NOT EXISTS<\/span> \u6216 <span style=\"background-color:#eff0f1\">LEFT JOIN &#8230; IS NULL<\/span>&#xff0c;\u6027\u80fd\u4e0e\u6b63\u786e\u6027\u90fd\u66f4\u4f18\u3002<\/span><\/li>\n<\/ul>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">4.3 DDL&#xff1a;\u6570\u636e\u5b9a\u4e49\u8bed\u8a00<\/span><\/h3>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u5efa\u8868\u793a\u4f8b&#xff08;PostgreSQL \u98ce\u683c&#xff09;<\/span><\/h4>\n<p>CREATE TABLE users (<br \/>\n\u00a0 user_id\u00a0\u00a0\u00a0\u00a0 BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,<br \/>\n\u00a0 email\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TEXT NOT NULL UNIQUE,<br \/>\n\u00a0 nickname\u00a0\u00a0\u00a0 TEXT,<br \/>\n\u00a0 status\u00a0\u00a0\u00a0\u00a0\u00a0 TEXT NOT NULL DEFAULT &#039;active&#039; CHECK (status IN (&#039;active&#039;, &#039;blocked&#039;, &#039;deleted&#039;)),<br \/>\n\u00a0 created_at\u00a0 TIMESTAMPTZ NOT NULL DEFAULT NOW(),<br \/>\n\u00a0 updated_at\u00a0 TIMESTAMPTZ NOT NULL DEFAULT NOW()<br \/>\n); <\/p>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u5e38\u89c1\u64cd\u4f5c<\/span><\/h4>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:#f5f6f7;border-color:#dee0e3;width:414.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">&#8212; \u52a0\u5217<\/span> \u00a0<\/p>\n<p> ALTER TABLE users ADD COLUMN last_login_at TIMESTAMPTZ; <\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">&#8212; \u5220\u8868<\/span> \u00a0<\/p>\n<p> DROP TABLE IF EXISTS tmp_import; <\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">&#8212; \u5efa\u7d22\u5f15<\/span><\/p>\n<p> CREATE INDEX idx_users_status ON users(status); <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u751f\u4ea7\u73af\u5883\u6ce8\u610f&#xff1a;<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5927\u8868 ALTER TABLE \u53ef\u80fd\u9501\u8868&#xff0c;\u5bfc\u81f4\u4e1a\u52a1\u4e0d\u53ef\u7528&#xff0c;\u4f7f\u7528\u5728\u7ebf DDL \u5de5\u5177&#xff08;\u5982 PostgreSQL \u7684 pg_repack&#xff09;\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4e34\u65f6\u8868\u547d\u540d\u89c4\u8303&#xff0c;\u7528\u5b8c\u53ca\u65f6\u6e05\u7406&#xff0c;\u907f\u514d\u7a7a\u95f4\u5360\u7528\u3002<\/span><\/li>\n<\/ul>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">4.4 DML&#xff1a;\u6570\u636e\u64cd\u4f5c\u8bed\u8a00<\/span><\/h3>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:#f5f6f7;border-color:#dee0e3;width:414.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">&#8212; \u63d2\u5165<\/span> \u00a0<\/p>\n<p> INSERT INTO users (email, nickname) VALUES (&#039;a&#064;example.com&#039;, &#039;Alice&#039;); <\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">&#8212; \u6279\u91cf\u63d2\u5165<\/span> \u00a0<\/p>\n<p> INSERT INTO users (email, nickname)<br \/>\nSELECT email, name FROM temp_users; <\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">&#8212; \u66f4\u65b0<\/span> \u00a0<\/p>\n<p> UPDATE users<br \/>\nSET status &#061; &#039;blocked&#039;, updated_at &#061; NOW()<br \/>\nWHERE user_id &#061; 1; <\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">&#8212; \u5220\u9664<\/span><\/p>\n<p> DELETE FROM users WHERE status &#061; &#039;deleted&#039;; <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u8fdb\u9636\u5199\u6cd5&#xff08;\u65b9\u8a00\u5dee\u5f02\u5927&#xff09;<\/span><\/h4>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">UPSERT&#xff1a;\u63d2\u5165\u6216\u66f4\u65b0&#xff08;PostgreSQL: <span style=\"background-color:#eff0f1\">ON CONFLICT &#8230; DO UPDATE<\/span>&#xff1b;MySQL: <span style=\"background-color:#eff0f1\">INSERT &#8230; ON DUPLICATE KEY UPDATE<\/span>&#xff09;<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u591a\u8868\u66f4\u65b0&#xff1a;UPDATE &#8230; FROM &#8230; \u5173\u8054\u5176\u4ed6\u8868\u66f4\u65b0<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">MERGE&#xff1a;SQL \u6807\u51c6\u8bed\u6cd5&#xff0c;\u540c\u65f6\u652f\u6301\u63d2\u5165\/\u66f4\u65b0\/\u5220\u9664&#xff0c;\u6570\u4ed3\u573a\u666f\u5e38\u7528<\/span><\/li>\n<\/ul>\n<h2 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#7030a0\">\u7b2c 05 \u7ae0 \u00b7 \u5b50\u67e5\u8be2\u4e0e CTE&#xff08;\u4e2d\u7ea7&#xff09;<\/span><\/h2>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">5.1 \u5b50\u67e5\u8be2\u7c7b\u578b<\/span><\/h3>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u6807\u91cf\u5b50\u67e5\u8be2<\/span><\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u8fd4\u56de\u5355\u4e2a\u503c&#xff0c;\u53ef\u51fa\u73b0\u5728 SELECT\u3001WHERE \u4e2d&#xff1a;<\/span><\/p>\n<p>SELECT *<br \/>\nFROM products<br \/>\nWHERE price &gt; (SELECT AVG(price) FROM products); <\/p>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u8868\u5b50\u67e5\u8be2<\/span><\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u8fd4\u56de\u591a\u884c\u591a\u5217&#xff0c;\u4f5c\u4e3a\u4e34\u65f6\u8868\u653e\u5728 FROM \u540e\u6216 IN \u4e2d&#xff1a;<\/span><\/p>\n<p>SELECT u.*<br \/>\nFROM users u<br \/>\nJOIN (<br \/>\n\u00a0 SELECT user_id, SUM(amount) AS total<br \/>\n\u00a0 FROM orders<br \/>\n\u00a0 GROUP BY user_id<br \/>\n) o ON u.user_id &#061; o.user_id<br \/>\nWHERE o.total &gt; 1000; <\/p>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u76f8\u5173\u5b50\u67e5\u8be2<\/span><\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5185\u5c42\u5f15\u7528\u5916\u5c42\u7684\u5217&#xff0c;\u9010\u884c\u6267\u884c&#xff0c;\u6027\u80fd\u901a\u5e38\u8f83\u5dee&#xff1a;<\/span><\/p>\n<p>&#8212; \u6bcf\u4e2a\u7528\u6237\u7684\u6700\u65b0\u8ba2\u5355\u91d1\u989d&#xff08;\u76f8\u5173\u5b50\u67e5\u8be2\u5199\u6cd5&#xff0c;\u4e0d\u63a8\u8350&#xff09;<br \/>\nSELECT<br \/>\n\u00a0 u.user_id,<br \/>\n\u00a0 (SELECT amount FROM orders o WHERE o.user_id &#061; u.user_id ORDER BY order_date DESC LIMIT 1)<br \/>\nFROM users u; <\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\"><span style=\"color:#646a73\">\u5927\u591a\u6570\u76f8\u5173\u5b50\u67e5\u8be2\u53ef\u6539\u5199\u4e3a<\/span><span style=\"color:#646a73\"> JOIN <\/span><span style=\"color:#646a73\">\u6216\u7a97\u53e3\u51fd\u6570&#xff0c;\u53ef\u8bfb\u6027\u4e0e\u6027\u80fd\u66f4\u597d\u3002<\/span><\/span><\/p>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">EXISTS \/ NOT EXISTS&#xff08;\u534a\u8fde\u63a5&#xff09;<\/span><\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5224\u65ad\u5b50\u67e5\u8be2\u662f\u5426\u6709\u5339\u914d\u884c&#xff0c;\u6027\u80fd\u4f18\u5f02&#xff0c;\u662f\u53cd\u8fde\u63a5\u7684\u9996\u9009\u5199\u6cd5&#xff1a;<\/span><\/p>\n<p>SELECT * FROM users u<br \/>\nWHERE EXISTS (<br \/>\n\u00a0 SELECT 1 FROM orders o<br \/>\n\u00a0 WHERE o.user_id &#061; u.user_id<br \/>\n\u00a0\u00a0\u00a0 AND o.amount &gt; 1000<br \/>\n); <\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">5.2 CTE&#xff1a;\u516c\u5171\u8868\u8868\u8fbe\u5f0f&#xff08;2026 \u4e2d\u7ea7\u6807\u914d&#xff09;<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7528 WITH \u7ed9\u4e2d\u95f4\u7ed3\u679c\u547d\u540d&#xff0c;\u628a\u590d\u6742\u67e5\u8be2\u62c6\u6210\u53ef\u8bfb\u7684\u6b65\u9aa4&#xff1a;<\/span><\/p>\n<p>WITH orders_2026 AS (<br \/>\n\u00a0 SELECT * FROM orders<br \/>\n\u00a0 WHERE order_date &gt;&#061; &#039;2026-01-01&#039;<br \/>\n),<br \/>\nuser_revenue AS (<br \/>\n\u00a0 SELECT user_id, SUM(amount) AS revenue<br \/>\n\u00a0 FROM orders_2026<br \/>\n\u00a0 GROUP BY user_id<br \/>\n)<br \/>\nSELECT * FROM user_revenue<br \/>\nWHERE revenue &gt; 1000<br \/>\nORDER BY revenue DESC; <\/p>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">CTE \u7684\u4ef7\u503c<\/span><\/h4>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u53ef\u8bfb\u6027&#xff1a;\u6309\u4e1a\u52a1\u903b\u8f91\u5206\u5c42&#xff0c;\u6bcf\u4e00\u6b65\u53ea\u505a\u4e00\u4ef6\u4e8b&#xff0c;\u4fbf\u4e8e\u7406\u89e3\u4e0e\u7ef4\u62a4\u3002<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u53ef\u590d\u7528&#xff1a;\u540c\u4e00\u4e2d\u95f4\u7ed3\u679c\u53ef\u5728\u540e\u7eed\u591a\u6b21\u5f15\u7528\u3002<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6613\u8c03\u8bd5&#xff1a;\u53ef\u5355\u72ec\u6267\u884c\u6bcf\u4e00\u4e2a CTE \u9a8c\u8bc1\u6570\u636e\u6b63\u786e\u6027\u3002<\/span><\/li>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u4f18\u5316\u5668\u6ce8\u610f\u4e8b\u9879<\/span><\/h4>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">PostgreSQL 12 \u53ca\u4ee5\u4e0a\u7248\u672c&#xff1a;\u666e\u901a CTE \u53ef\u88ab\u4f18\u5316\u5668\u5185\u8054&#xff0c;\u548c\u5b50\u67e5\u8be2\u6027\u80fd\u4e00\u81f4\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u65e7\u7248\u672c PostgreSQL&#xff1a;CTE \u662f\u300c\u4f18\u5316\u56f4\u5899\u300d&#xff0c;\u4f18\u5316\u5668\u65e0\u6cd5\u4e0b\u63a8\u6761\u4ef6&#xff0c;\u5927\u8868\u573a\u666f\u53ef\u80fd\u6027\u80fd\u4e0b\u964d\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">DuckDB\u3001Snowflake \u7b49\u5206\u6790\u5f15\u64ce&#xff1a;CTE \u4f18\u5316\u6210\u719f&#xff0c;\u653e\u5fc3\u4f7f\u7528\u3002<\/span><\/li>\n<\/ul>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">5.3 \u9012\u5f52 CTE<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7528\u4e8e\u5904\u7406\u6811\u72b6\u7ed3\u6784\u3001\u5c42\u7ea7\u5173\u7cfb\u3001\u8def\u5f84\u5c55\u5f00&#xff08;\u5982\u7ec4\u7ec7\u67b6\u6784\u3001\u5206\u7c7b\u6811\u3001BOM&#xff09;&#xff1a;<\/span><\/p>\n<p>WITH RECURSIVE employee_tree AS (<br \/>\n\u00a0 &#8212; \u951a\u70b9&#xff1a;\u6839\u8282\u70b9<br \/>\n\u00a0 SELECT employee_id, manager_id, name, 1 AS level<br \/>\n\u00a0 FROM employees<br \/>\n\u00a0 WHERE manager_id IS NULL<\/p>\n<p>\u00a0 UNION ALL<\/p>\n<p>\u00a0 &#8212; \u9012\u5f52\u90e8\u5206&#xff1a;\u8fde\u63a5\u4e0a\u4e00\u5c42\u7ed3\u679c<br \/>\n\u00a0 SELECT e.employee_id, e.manager_id, e.name, t.level &#043; 1<br \/>\n\u00a0 FROM employees e<br \/>\n\u00a0 JOIN employee_tree t ON e.manager_id &#061; t.employee_id<br \/>\n)<br \/>\nSELECT * FROM employee_tree; <\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5fc5\u987b\u5305\u542b\u951a\u70b9 &#043; \u9012\u5f52\u90e8\u5206&#xff0c;\u7528 UNION ALL \u8fde\u63a5\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6ce8\u610f\u9632\u6b62\u6b7b\u5faa\u73af&#xff1a;\u90e8\u5206\u5f15\u64ce\u652f\u6301 <span style=\"background-color:#eff0f1\">CYCLE<\/span> \u5b50\u53e5\u68c0\u6d4b\u73af\u3002<\/span><\/li>\n<\/ul>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">5.4 CASE \u4e0e\u6761\u4ef6\u805a\u5408<\/span><\/h3>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u6807\u51c6 CASE \u5199\u6cd5&#xff08;\u5168\u65b9\u8a00\u901a\u7528&#xff09;<\/span><\/h4>\n<p>SELECT<br \/>\n\u00a0 user_id,<br \/>\n\u00a0 SUM(CASE WHEN status &#061; &#039;paid&#039; THEN amount ELSE 0 END) AS paid_amount,<br \/>\n\u00a0 SUM(CASE WHEN status &#061; &#039;refunded&#039; THEN amount ELSE 0 END) AS refund_amount,<br \/>\n\u00a0 COUNT(CASE WHEN status &#061; &#039;paid&#039; THEN 1 END) AS paid_order_cnt<br \/>\nFROM orders<br \/>\nGROUP BY user_id; <\/p>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">FILTER \u5b50\u53e5&#xff08;\u66f4\u7b80\u6d01&#xff0c;PostgreSQL\/DuckDB \u652f\u6301&#xff09;<\/span><\/h4>\n<p>SELECT<br \/>\n\u00a0 user_id,<br \/>\n\u00a0 SUM(amount) FILTER (WHERE status &#061; &#039;paid&#039;) AS paid_amount,<br \/>\n\u00a0 COUNT(*) FILTER (WHERE status &#061; &#039;refunded&#039;) AS refund_cnt<br \/>\nFROM orders<br \/>\nGROUP BY user_id; <\/p>\n<h2 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#7030a0\">\u7b2c 06 \u7ae0 \u00b7 \u7a97\u53e3\u51fd\u6570&#xff08;\u4e2d\u7ea7\u6838\u5fc3&#xff09;<\/span><\/h2>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7a97\u53e3\u51fd\u6570\u662f\u6570\u636e\u5206\u6790\u5c97\u4f4d\u7684\u6838\u5fc3\u5206\u754c\u7ebf&#xff0c;\u5b83\u5728\u4e0d\u584c\u7f29\u884c\u6570\u7684\u524d\u63d0\u4e0b&#xff0c;\u5b9e\u73b0\u5206\u7ec4\u5185\u8ba1\u7b97\u3002<\/span><\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">6.1 \u57fa\u672c\u8bed\u6cd5\u6846\u67b6<\/span><\/h3>\n<p>\u51fd\u6570\u540d(\u53c2\u6570) OVER (<br \/>\n\u00a0 PARTITION BY \u5206\u7ec4\u5217\u00a0\u00a0\u00a0\u00a0\u00a0 &#8212; \u7a97\u53e3\u6309\u4ec0\u4e48\u5206\u7ec4&#xff0c;\u7c7b\u4f3c GROUP BY \u4f46\u4e0d\u5408\u5e76\u884c<br \/>\n\u00a0 ORDER BY \u6392\u5e8f\u5217\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8212; \u7a97\u53e3\u5185\u7684\u6392\u5e8f&#xff0c;\u6392\u540d\u3001\u7d2f\u8ba1\u3001\u73af\u6bd4\u4f9d\u8d56\u5b83<br \/>\n\u00a0 ROWS\/RANGE \u5e27\u8303\u56f4\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8212; \u7a97\u53e3\u8986\u76d6\u54ea\u4e9b\u884c&#xff0c;\u7d2f\u8ba1\u4e0e\u6ed1\u52a8\u5e73\u5747\u5173\u952e<br \/>\n) <\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">6.2 \u6392\u540d\u7c7b\u7a97\u53e3\u51fd\u6570<\/span><\/h3>\n<table cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u51fd\u6570<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7279\u70b9<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5e76\u5217\u540d\u6b21\u5904\u7406<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#fbe4d5;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">ROW_NUMBER()<\/span><\/span><\/p>\n<\/td>\n<td style=\"background-color:#fbe4d5;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5f3a\u5236\u8fde\u7eed\u5e8f\u53f7&#xff0c;\u5e76\u5217\u4e5f\u6309\u987a\u5e8f\u6392 1,2,3<\/span><\/p>\n<\/td>\n<td style=\"background-color:#fbe4d5;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4e0d\u91cd\u590d<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">RANK()<\/span><\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5e76\u5217\u540c\u540d\u6b21&#xff0c;\u4e0b\u4e00\u540d\u8df3\u53f7&#xff1a;1,1,3<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u8df3\u53f7<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#fbe4d5;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">DENSE_RANK()<\/span><\/span><\/p>\n<\/td>\n<td style=\"background-color:#fbe4d5;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5e76\u5217\u540c\u540d\u6b21&#xff0c;\u4e0b\u4e00\u540d\u4e0d\u8df3\u53f7&#xff1a;1,1,2<\/span><\/p>\n<\/td>\n<td style=\"background-color:#fbe4d5;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4e0d\u8df3\u53f7<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">NTILE(n)<\/span><\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u628a\u6570\u636e\u5206\u6210 n \u4e2a\u6876&#xff0c;\u8fd4\u56de\u6876\u7f16\u53f7<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5747\u5206\u5206\u7ec4<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7ecf\u5178\u573a\u666f&#xff1a;\u53d6\u6bcf\u4e2a\u7528\u6237\u6700\u65b0\u7684\u4e00\u7b14\u8ba2\u5355<\/span><\/p>\n<p>WITH ranked_orders AS (<br \/>\n\u00a0 SELECT<br \/>\n\u00a0\u00a0\u00a0 user_id, order_id, amount, order_date,<br \/>\n\u00a0\u00a0\u00a0 ROW_NUMBER() OVER (<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0 PARTITION BY user_id<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0 ORDER BY order_date DESC, order_id DESC<br \/>\n\u00a0\u00a0\u00a0 ) AS rn<br \/>\n\u00a0 FROM orders<br \/>\n)<br \/>\nSELECT * FROM ranked_orders WHERE rn &#061; 1; <\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">6.3 \u53d6\u503c\u7c7b\u7a97\u53e3\u51fd\u6570<\/span><\/h3>\n<table cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:white;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u51fd\u6570<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4f5c\u7528<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#d9e2f3;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">LAG(col, n)<\/span><\/span><\/p>\n<\/td>\n<td style=\"background-color:#d9e2f3;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u53d6\u5f53\u524d\u884c\u5f80\u524d\u7b2c n \u884c\u7684\u503c&#xff08;\u73af\u6bd4\u5e38\u7528&#xff09;<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">LEAD(col, n)<\/span><\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u53d6\u5f53\u524d\u884c\u5f80\u540e\u7b2c n \u884c\u7684\u503c<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#d9e2f3;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">FIRST_VALUE(col)<\/span><\/span><\/p>\n<\/td>\n<td style=\"background-color:#d9e2f3;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u53d6\u7a97\u53e3\u5185\u7b2c\u4e00\u884c\u7684\u503c<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">LAST_VALUE(col)<\/span><\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u53d6\u7a97\u53e3\u5185\u6700\u540e\u4e00\u884c\u7684\u503c&#xff08;\u6ce8\u610f\u5e27\u8303\u56f4&#xff09;<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#d9e2f3;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">NTH_VALUE(col, n)<\/span><\/span><\/p>\n<\/td>\n<td style=\"background-color:#d9e2f3;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u53d6\u7a97\u53e3\u5185\u7b2c n \u884c\u7684\u503c<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7ecf\u5178\u573a\u666f&#xff1a;\u65e5\u9500\u552e\u989d\u73af\u6bd4<\/span><\/p>\n<p>SELECT<br \/>\n\u00a0 order_date,<br \/>\n\u00a0 revenue,<br \/>\n\u00a0 LAG(revenue) OVER (ORDER BY order_date) AS prev_day_revenue,<br \/>\n\u00a0 ROUND(<br \/>\n\u00a0\u00a0\u00a0 (revenue &#8211; LAG(revenue) OVER (ORDER BY order_date))<br \/>\n\u00a0\u00a0\u00a0 \/ LAG(revenue) OVER (ORDER BY order_date) * 100,<br \/>\n\u00a0\u00a0\u00a0 2<br \/>\n\u00a0 ) AS wow_rate<br \/>\nFROM daily_revenue; <\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">6.4 \u7d2f\u8ba1\u4e0e\u6ed1\u52a8\u7a97\u53e3<\/span><\/h3>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u5e27\u5b50\u53e5\u4e09\u79cd\u7c7b\u578b<\/span><\/h4>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">ROWS&#xff1a;\u6309\u7269\u7406\u884c\u8ba1\u6570&#xff0c;\u7cbe\u786e\u5230\u884c<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">RANGE&#xff1a;\u6309\u6392\u5e8f\u952e\u7684\u503c\u8303\u56f4&#xff0c;\u76f8\u540c\u503c\u7684\u884c\u89c6\u4e3a\u540c\u4e00\u7ec4<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">GROUPS&#xff1a;\u6309\u6392\u5e8f\u952e\u7684\u5206\u7ec4\u8ba1\u6570&#xff08;SQL:2011 \u6807\u51c6&#xff0c;\u90e8\u5206\u5f15\u64ce\u652f\u6301&#xff09;<\/span><\/li>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u5e38\u7528\u5e27\u5199\u6cd5<\/span><\/h4>\n<p>&#8212; \u7d2f\u8ba1\u6c42\u548c&#xff1a;\u4ece\u7a97\u53e3\u5f00\u5934\u5230\u5f53\u524d\u884c&#xff08;\u9ed8\u8ba4\u5e27&#xff0c;ORDER BY \u540e\u9ed8\u8ba4\u5c31\u662f\u8fd9\u4e2a&#xff09;<br \/>\nSUM(amount) OVER (<br \/>\n\u00a0 PARTITION BY user_id<br \/>\n\u00a0 ORDER BY order_date<br \/>\n\u00a0 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW<br \/>\n) AS running_total<\/p>\n<p>&#8212; \u8fd1 7 \u5929\u6ed1\u52a8\u5e73\u5747&#xff08;\u7269\u7406\u884c&#xff09;<br \/>\nAVG(amount) OVER (<br \/>\n\u00a0 ORDER BY order_date<br \/>\n\u00a0 ROWS BETWEEN 6 PRECEDING AND CURRENT ROW<br \/>\n) AS avg_7d <\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\"><span style=\"color:#646a73\">\u6ce8\u610f&#xff1a;\u53ea\u5199<\/span><span style=\"color:#646a73\"> ORDER BY <\/span><span style=\"color:#646a73\">\u4e0d\u5199\u5e27\u5b50\u53e5\u65f6&#xff0c;\u9ed8\u8ba4\u5e27\u662f<\/span> <span style=\"background-color:#eff0f1\"><span style=\"color:#646a73\">RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW<\/span><\/span><span style=\"color:#646a73\">&#xff0c;\u6392\u5e8f\u952e\u6709\u91cd\u590d\u503c\u65f6&#xff0c;<\/span><span style=\"color:#646a73\">ROWS <\/span><span style=\"color:#646a73\">\u548c<\/span><span style=\"color:#646a73\"> RANGE <\/span><span style=\"color:#646a73\">\u7ed3\u679c\u4e0d\u540c&#xff0c;\u9700\u7279\u522b\u6ce8\u610f\u3002<\/span><\/span><\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">6.5 \u805a\u5408\u7c7b\u7a97\u53e3\u51fd\u6570<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">SUM \/ AVG \/ COUNT \/ MIN \/ MAX \u90fd\u53ef\u4ee5\u4f5c\u4e3a\u7a97\u53e3\u51fd\u6570\u4f7f\u7528&#xff0c;\u5b9e\u73b0\u300c\u660e\u7ec6\u884c &#043; \u5206\u7ec4\u805a\u5408\u503c\u300d\u540c\u5c4f\u5c55\u793a<\/span><\/p>\n<p>SELECT<br \/>\n\u00a0 order_id, user_id, amount,<br \/>\n\u00a0 SUM(amount) OVER (PARTITION BY user_id) AS user_total_amount,<br \/>\n\u00a0 amount \/ SUM(amount) OVER (PARTITION BY user_id) AS user_amount_ratio<br \/>\nFROM orders; <\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">6.6 \u7a97\u53e3\u51fd\u6570 vs GROUP BY<\/span><\/h3>\n<table cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7ef4\u5ea6<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">GROUP BY<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7a97\u53e3\u51fd\u6570<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#cccccc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u884c\u6570\u53d8\u5316<\/span><\/p>\n<\/td>\n<td style=\"background-color:#cccccc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u584c\u7f29&#xff0c;\u6bcf\u7ec4\u4e00\u884c<\/span><\/p>\n<\/td>\n<td style=\"background-color:#cccccc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4e0d\u53d8&#xff0c;\u4fdd\u7559\u539f\u59cb\u660e\u7ec6\u884c\u6570<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u8f93\u51fa\u5185\u5bb9<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u53ea\u6709\u5206\u7ec4\u952e\u4e0e\u805a\u5408\u503c<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u660e\u7ec6 &#043; \u7a97\u53e3\u8ba1\u7b97\u503c<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#cccccc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5178\u578b\u7528\u9014<\/span><\/p>\n<\/td>\n<td style=\"background-color:#cccccc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6c47\u603b\u62a5\u8868\u3001\u6307\u6807\u7edf\u8ba1<\/span><\/p>\n<\/td>\n<td style=\"background-color:#cccccc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6392\u540d\u3001\u73af\u6bd4\u3001\u7d2f\u8ba1\u3001\u6253\u6807\u8fc7\u6ee4<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7ec4\u5408\u4f7f\u7528<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u53ef\u5148\u7a97\u53e3\u6253\u6807&#xff0c;\u518d\u805a\u5408<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u53ef\u5d4c\u5957\u5728 CTE \u4e2d\u591a\u5c42\u8ba1\u7b97<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">6.7 \u9ad8\u9891\u4e1a\u52a1\u9898\u578b<\/span><\/h3>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6bcf\u7528\u6237\u6700\u65b0\/\u6700\u65e9\u4e00\u7b14\u8ba2\u5355<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">Top N per group&#xff08;\u6bcf\u7c7b\u76ee\u9500\u91cf\u524d 3&#xff09;<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u7528\u6237\u7559\u5b58\u5206\u6790&#xff08;\u9996\u6b21\u6d3b\u8dc3\u540e\u7b2c N \u65e5\u56de\u8bbf&#xff09;<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6f0f\u6597\u8f6c\u5316\u8ba1\u7b97&#xff08;\u6b65\u9aa4\u5230\u8fbe\u7387&#xff09;<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u8fde\u7eed\u767b\u5f55\u5929\u6570&#xff08;\u5c9b\u5c7f\u95ee\u9898&#xff09;<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u540c\u6bd4\/\u73af\u6bd4\/\u6eda\u52a8\u5e73\u5747<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u53bb\u91cd\u4fdd\u7559\u6700\u65b0\u7248\u672c\u6570\u636e<\/span><\/li>\n<h2 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#7030a0\">\u7b2c 07 \u7ae0 \u00b7 \u89c6\u56fe\u3001\u4e8b\u52a1\u4e0e\u7d22\u5f15\u76f4\u89c9&#xff08;\u4e2d\u7ea7&#xff09;<\/span><\/h2>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">7.1 \u89c6\u56fe&#xff08;VIEW&#xff09;<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u89c6\u56fe\u662f\u4fdd\u5b58\u8d77\u6765\u7684\u67e5\u8be2\u5b9a\u4e49&#xff0c;\u4f7f\u7528\u8d77\u6765\u50cf\u8868\u4e00\u6837&#xff1a;<\/span><\/p>\n<p>CREATE VIEW v_user_monthly_revenue AS<br \/>\nSELECT<br \/>\n\u00a0 user_id,<br \/>\n\u00a0 DATE_TRUNC(&#039;month&#039;, order_date) AS order_month,<br \/>\n\u00a0 SUM(amount) AS revenue<br \/>\nFROM orders<br \/>\nGROUP BY user_id, DATE_TRUNC(&#039;month&#039;, order_date); <\/p>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u4f5c\u7528<\/span><\/h4>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u903b\u8f91\u590d\u7528&#xff1a;\u590d\u6742\u67e5\u8be2\u5c01\u88c5&#xff0c;\u4e0a\u5c42\u8c03\u7528\u7b80\u5355<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6743\u9650\u9694\u79bb&#xff1a;\u53ea\u7ed9\u7528\u6237\u5f00\u653e\u90e8\u5206\u5217\/\u90e8\u5206\u884c<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u7b80\u5316\u4e0a\u5c42\u67e5\u8be2&#xff1a;\u9690\u85cf\u590d\u6742\u7684 JOIN \u548c\u805a\u5408\u903b\u8f91<\/span><\/li>\n<\/ul>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u6ce8\u610f\u4e8b\u9879<\/span><\/h4>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u89c6\u56fe\u672c\u8eab\u4e0d\u5b58\u50a8\u6570\u636e&#xff08;\u9664\u7269\u5316\u89c6\u56fe&#xff09;&#xff0c;\u67e5\u8be2\u65f6\u6267\u884c\u5e95\u5c42 SQL&#xff0c;\u590d\u6742\u89c6\u56fe\u53ef\u80fd\u6027\u80fd\u5f88\u5dee\u3002<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4e0d\u8981\u5d4c\u5957\u8fc7\u6df1\u89c6\u56fe&#xff0c;\u591a\u5c42\u5d4c\u5957\u4f1a\u5bfc\u81f4\u4f18\u5316\u5668\u5931\u6548&#xff0c;\u6027\u80fd\u6307\u6570\u7ea7\u4e0b\u964d\u3002<\/span><\/li>\n<\/ul>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u7269\u5316\u89c6\u56fe&#xff08;Materialized View&#xff09;<\/span><\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u9884\u8ba1\u7b97\u7ed3\u679c\u5e76\u843d\u76d8&#xff0c;\u67e5\u8be2\u76f4\u63a5\u8bfb\u7ed3\u679c&#xff0c;\u6362\u67e5\u8be2\u901f\u5ea6\u3002\u9700\u8981\u5b9a\u65f6\u5237\u65b0&#xff0c;\u9002\u7528\u4e8e\u53d8\u5316\u4e0d\u9891\u7e41\u7684\u6c47\u603b\u6307\u6807\u3002<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">PostgreSQL \u539f\u751f\u652f\u6301&#xff0c;\u53ef\u624b\u52a8\u5237\u65b0<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6570\u4ed3\u5f15\u64ce&#xff08;Snowflake\u3001ClickHouse&#xff09;\u6709\u66f4\u4e30\u5bcc\u7684\u7269\u5316\u89c6\u56fe\u80fd\u529b<\/span><\/li>\n<\/ul>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">7.2 \u4e8b\u52a1\u4e0e ACID<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4e8b\u52a1\u662f\u4e00\u7ec4 SQL \u64cd\u4f5c\u7684\u96c6\u5408&#xff0c;\u8981\u4e48\u5168\u90e8\u6210\u529f&#xff0c;\u8981\u4e48\u5168\u90e8\u5931\u8d25\u3002<\/span><\/p>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">ACID \u56db\u5927\u7279\u6027<\/span><\/h4>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u539f\u5b50\u6027&#xff08;Atomicity&#xff09;&#xff1a;\u4e8b\u52a1\u662f\u4e0d\u53ef\u5206\u5272\u7684\u6700\u5c0f\u5355\u5143&#xff0c;\u5168\u6210\u529f\u6216\u5168\u56de\u6eda<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4e00\u81f4\u6027&#xff08;Consistency&#xff09;&#xff1a;\u4e8b\u52a1\u524d\u540e&#xff0c;\u6570\u636e\u59cb\u7ec8\u4fdd\u6301\u4e1a\u52a1\u89c4\u5219\u4e00\u81f4<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u9694\u79bb\u6027&#xff08;Isolation&#xff09;&#xff1a;\u591a\u4e2a\u4e8b\u52a1\u5e76\u53d1\u6267\u884c&#xff0c;\u4e92\u76f8\u4e0d\u5e72\u6270<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6301\u4e45\u6027&#xff08;Durability&#xff09;&#xff1a;\u4e8b\u52a1\u63d0\u4ea4\u540e&#xff0c;\u6570\u636e\u6c38\u4e45\u751f\u6548&#xff0c;\u5b95\u673a\u4e0d\u4e22\u5931<\/span><\/li>\n<\/ul>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u4e8b\u52a1\u8bed\u6cd5<\/span><\/h4>\n<p>BEGIN;\u00a0\u00a0\u00a0 &#8212; \u5f00\u542f\u4e8b\u52a1<br \/>\nUPDATE accounts SET balance &#061; balance &#8211; 100 WHERE id &#061; 1;<br \/>\nUPDATE accounts SET balance &#061; balance &#043; 100 WHERE id &#061; 2;<br \/>\nCOMMIT;\u00a0\u00a0 &#8212; \u63d0\u4ea4\u4e8b\u52a1<br \/>\n&#8212; ROLLBACK;\u00a0 &#8212; \u56de\u6eda\u4e8b\u52a1 <\/p>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u9694\u79bb\u7ea7\u522b\u4e0e\u5e76\u53d1\u95ee\u9898<\/span><\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4ece\u5f31\u5230\u5f3a&#xff1a;\u8bfb\u672a\u63d0\u4ea4 \u2192 \u8bfb\u5df2\u63d0\u4ea4&#xff08;RC&#xff0c;\u5927\u591a\u6570\u6570\u636e\u5e93\u9ed8\u8ba4&#xff09; \u2192 \u53ef\u91cd\u590d\u8bfb&#xff08;RR&#xff0c;MySQL InnoDB \u9ed8\u8ba4&#xff09; \u2192 \u53ef\u4e32\u884c\u5316\u3002<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5bf9\u5e94\u5e76\u53d1\u95ee\u9898&#xff1a;<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u810f\u8bfb&#xff1a;\u8bfb\u5230\u5176\u4ed6\u4e8b\u52a1\u672a\u63d0\u4ea4\u7684\u6570\u636e<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4e0d\u53ef\u91cd\u590d\u8bfb&#xff1a;\u540c\u4e00\u4e8b\u52a1\u5185&#xff0c;\u4e24\u6b21\u8bfb\u540c\u4e00\u884c\u7ed3\u679c\u4e0d\u540c<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5e7b\u8bfb&#xff1a;\u540c\u4e00\u4e8b\u52a1\u5185&#xff0c;\u4e24\u6b21\u8303\u56f4\u67e5\u8be2\u884c\u6570\u4e0d\u540c<\/span><\/li>\n<\/ul>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\"><span style=\"color:#646a73\">OLTP <\/span><span style=\"color:#646a73\">\u4e1a\u52a1\u5fc5\u987b\u7406\u89e3\u4e8b\u52a1\u8fb9\u754c\u4e0e\u9694\u79bb\u7ea7\u522b&#xff1b;\u7eaf\u5206\u6790\u6279\u5904\u7406\u66f4\u5173\u6ce8\u4f5c\u4e1a\u5e42\u7b49\u4e0e\u5206\u533a\u8986\u76d6&#xff0c;\u800c\u975e\u884c\u7ea7\u9501\u7ec6\u8282\u3002<\/span><\/span><\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">7.3 \u7d22\u5f15\u76f4\u89c9<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7d22\u5f15\u662f\u300c\u7528\u7a7a\u95f4\u6362\u65f6\u95f4\u300d\u7684\u6570\u636e\u7ed3\u6784&#xff0c;\u5e2e\u52a9\u6570\u636e\u5e93\u5feb\u901f\u5b9a\u4f4d\u884c\u3002<\/span><\/p>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u6700\u5e38\u89c1\u7c7b\u578b\u4e0e\u9002\u7528\u573a\u666f<\/span><\/h4>\n<table cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:white;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7d22\u5f15\u7c7b\u578b<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5e95\u5c42\u7ed3\u6784<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u9002\u7528\u573a\u666f<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4ee3\u8868\u5f15\u64ce<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#e2efd9;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">B-Tree \u7d22\u5f15<\/span><\/p>\n<\/td>\n<td style=\"background-color:#e2efd9;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">B&#043;\u6811<\/span><\/p>\n<\/td>\n<td style=\"background-color:#e2efd9;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7b49\u503c\u67e5\u8be2\u3001\u8303\u56f4\u67e5\u8be2\u3001\u6392\u5e8f\u3001JOIN \u952e&#xff0c;\u6700\u901a\u7528<\/span><\/p>\n<\/td>\n<td style=\"background-color:#e2efd9;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6240\u6709\u5173\u7cfb\u578b\u6570\u636e\u5e93<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u54c8\u5e0c\u7d22\u5f15<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u54c8\u5e0c\u8868<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4ec5\u7b49\u503c\u67e5\u8be2&#xff0c;\u901f\u5ea6\u6781\u5feb&#xff0c;\u4e0d\u652f\u6301\u8303\u56f4\u4e0e\u6392\u5e8f<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">MySQL Memory\u3001PostgreSQL<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#e2efd9;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">GIN \u7d22\u5f15<\/span><\/p>\n<\/td>\n<td style=\"background-color:#e2efd9;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5012\u6392\u7d22\u5f15<\/span><\/p>\n<\/td>\n<td style=\"background-color:#e2efd9;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6570\u7ec4\u3001JSONB\u3001\u5168\u6587\u641c\u7d22&#xff0c;\u591a\u503c\u5339\u914d<\/span><\/p>\n<\/td>\n<td style=\"background-color:#e2efd9;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">PostgreSQL<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">GiST \u7d22\u5f15<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u901a\u7528\u641c\u7d22\u6811<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5730\u7406\u7a7a\u95f4\u3001\u5168\u6587\u641c\u7d22\u3001\u6a21\u7cca\u67e5\u8be2<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">PostgreSQL<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#e2efd9;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">BRIN \u7d22\u5f15<\/span><\/p>\n<\/td>\n<td style=\"background-color:#e2efd9;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5757\u8303\u56f4\u7d22\u5f15<\/span><\/p>\n<\/td>\n<td style=\"background-color:#e2efd9;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u65f6\u5e8f\u6570\u636e\u3001\u6709\u5e8f\u5927\u8868&#xff0c;\u4f53\u79ef\u6781\u5c0f<\/span><\/p>\n<\/td>\n<td style=\"background-color:#e2efd9;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">PostgreSQL<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4f4d\u56fe\u7d22\u5f15<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4f4d\u56fe<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4f4e\u57fa\u6570\u5217&#xff08;\u6027\u522b\u3001\u72b6\u6001&#xff09;&#xff0c;\u6570\u636e\u4ed3\u5e93<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:103.5pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">Oracle\u3001Greenplum<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u7d22\u5f15\u5931\u6548\u5e38\u89c1\u573a\u666f<\/span><\/h4>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5bf9\u7d22\u5f15\u5217\u4f7f\u7528\u51fd\u6570\/\u8fd0\u7b97&#xff1a;<span style=\"background-color:#eff0f1\">WHERE DATE(created_at) &#061; &#039;2026-01-01&#039;<\/span><\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362&#xff1a;\u5b57\u7b26\u4e32\u5217\u7528\u6570\u5b57\u6bd4\u8f83<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u524d\u5bfc\u901a\u914d\u7b26\u6a21\u7cca\u67e5\u8be2&#xff1a;<span style=\"background-color:#eff0f1\">LIKE &#039;%keyword%&#039;<\/span><\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4f7f\u7528 <span style=\"background-color:#eff0f1\">NOT<\/span>\u3001<span style=\"background-color:#eff0f1\">!&#061;<\/span>\u3001<span style=\"background-color:#eff0f1\">&lt;&gt;<\/span> \u53cd\u5411\u67e5\u8be2&#xff08;\u6570\u636e\u91cf\u5927\u65f6\u5931\u6548&#xff09;<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">OR \u8fde\u63a5\u7684\u6761\u4ef6\u4e2d\u6709\u975e\u7d22\u5f15\u5217<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u9009\u62e9\u6027\u6781\u5dee\u7684\u5217&#xff08;\u5982\u6027\u522b&#xff09;\u5efa\u7d22\u5f15\u6536\u76ca\u6781\u4f4e<\/span><\/li>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u590d\u5408\u7d22\u5f15\u4e0e\u6700\u5de6\u524d\u7f00\u539f\u5219<\/span><\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u590d\u5408\u7d22\u5f15 <span style=\"background-color:#eff0f1\">(a, b, c)<\/span>&#xff1a;<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u652f\u6301\u67e5\u8be2&#xff1a;<span style=\"background-color:#eff0f1\">a<\/span>\u3001<span style=\"background-color:#eff0f1\">a&#043;b<\/span>\u3001<span style=\"background-color:#eff0f1\">a&#043;b&#043;c<\/span><\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4e0d\u652f\u6301&#xff1a;<span style=\"background-color:#eff0f1\">b<\/span>\u3001<span style=\"background-color:#eff0f1\">c<\/span>\u3001<span style=\"background-color:#eff0f1\">b&#043;c<\/span><\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u7b49\u503c\u67e5\u8be2\u5217\u653e\u524d\u9762&#xff0c;\u8303\u56f4\u67e5\u8be2\u5217\u653e\u540e\u9762<\/span><\/li>\n<\/ul>\n<h2 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#7030a0\">\u7b2c 08 \u7ae0 \u00b7 \u67e5\u8be2\u4f18\u5316\u4e0e\u6570\u636e\u5efa\u6a21&#xff08;\u9ad8\u7ea7&#xff09;<\/span><\/h2>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">8.1 \u5148\u6b63\u786e&#xff0c;\u518d\u5feb<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4f18\u5316\u7684\u524d\u63d0\u662f\u903b\u8f91\u6b63\u786e&#xff1a;\u7c92\u5ea6\u51c6\u786e\u3001JOIN \u4e0d\u81a8\u80c0\u3001NULL \u5904\u7406\u7b26\u5408\u4e1a\u52a1\u3001\u8fb9\u754c\u6761\u4ef6\u5b8c\u6574\u3002 \u9519\u8bef\u7684\u5feb\u67e5\u8be2\u6ca1\u6709\u4efb\u4f55\u4ef7\u503c&#xff0c;\u751a\u81f3\u4f1a\u5e26\u6765\u4e1a\u52a1\u635f\u5931\u3002<\/span><\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">8.2 \u6267\u884c\u8ba1\u5212\u89e3\u8bfb<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4f7f\u7528 <span style=\"background-color:#eff0f1\">EXPLAIN ANALYZE<\/span> \u67e5\u770b\u5b9e\u9645\u6267\u884c\u8def\u5f84\u4e0e\u8017\u65f6&#xff08;PostgreSQL \u793a\u4f8b&#xff09;&#xff1a;<\/span><\/p>\n<p>EXPLAIN ANALYZE<br \/>\nSELECT user_id, SUM(amount)<br \/>\nFROM orders<br \/>\nWHERE order_date &gt;&#061; &#039;2026-01-01&#039;<br \/>\nGROUP BY user_id; <\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5173\u6ce8\u6838\u5fc3\u70b9<\/span><\/p>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u8bbf\u95ee\u8def\u5f84&#xff1a;Seq Scan&#xff08;\u5168\u8868\u626b\u63cf&#xff09;\u3001Index Scan&#xff08;\u7d22\u5f15\u626b\u63cf&#xff09;\u3001Index Only Scan&#xff08;\u7d22\u5f15\u8986\u76d6\u626b\u63cf&#xff0c;\u6700\u4f18&#xff09;<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">JOIN \u7b97\u6cd5&#xff1a;<\/span><\/li>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">Nested Loop&#xff1a;\u5c0f\u8868\u9a71\u52a8\u5927\u8868&#xff0c;\u6709\u7d22\u5f15\u65f6\u5feb<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">Hash Join&#xff1a;\u5927\u8868\u5173\u8054&#xff0c;\u65e0\u7d22\u5f15\u65f6\u5e38\u7528&#xff0c;OLAP \u4e3b\u6d41<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">Merge Join&#xff1a;\u4e24\u4e2a\u6709\u5e8f\u6570\u636e\u96c6\u5173\u8054&#xff0c;\u6392\u5e8f\u540e\u5408\u5e76<\/span><\/li>\n<\/ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4f30\u7b97\u884c\u6570 vs \u5b9e\u9645\u884c\u6570&#xff1a;\u504f\u5dee\u5927\u8bf4\u660e\u7edf\u8ba1\u4fe1\u606f\u8fc7\u671f&#xff0c;\u9700 <span style=\"background-color:#eff0f1\">ANALYZE<\/span> \u8868<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6602\u8d35\u8282\u70b9&#xff1a;Sort\u3001HashAggregate\u3001\u91cd\u590d\u7269\u5316\u3001\u5927\u8868\u5168\u8868\u626b\u63cf<\/span><\/li>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">8.3 \u5e38\u89c1\u75c5\u7076\u4e0e\u4f18\u5316\u624b\u6bb5<\/span><\/h3>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">**SELECT ***&#xff1a;\u53ea\u67e5\u9700\u8981\u7684\u5217&#xff0c;\u51cf\u5c11 IO \u4e0e\u5185\u5b58\u5360\u7528<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5bbd\u677e JOIN \u540e\u518d\u8fc7\u6ee4&#xff1a;\u5148\u8fc7\u6ee4\u518d JOIN&#xff0c;\u7f29\u5c0f\u53c2\u4e0e\u5173\u8054\u7684\u6570\u636e\u91cf<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u9690\u5f0f\u8f6c\u6362&#xff1a;\u7edf\u4e00\u7c7b\u578b&#xff0c;\u4fdd\u8bc1\u7d22\u5f15\u53ef\u7528<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u76f8\u5173\u5b50\u67e5\u8be2&#xff1a;\u6539\u5199\u4e3a JOIN \u6216\u7a97\u53e3\u51fd\u6570<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4e0d\u5fc5\u8981\u7684 DISTINCT&#xff1a;\u627e\u5230\u91cd\u590d\u6839\u6e90&#xff0c;\u4ece\u6e90\u5934\u6d88\u9664<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5927\u7ed3\u679c\u6392\u5e8f&#xff1a;\u6392\u5e8f\u5b57\u6bb5\u52a0\u7d22\u5f15&#xff0c;\u6216\u51cf\u5c11\u6392\u5e8f\u6570\u636e\u91cf<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u7edf\u8ba1\u4fe1\u606f\u8fc7\u671f&#xff1a;\u5b9a\u671f ANALYZE \u8868&#xff0c;\u4fdd\u8bc1\u4f18\u5316\u5668\u5224\u65ad\u51c6\u786e<\/span><\/li>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4e91\u6570\u4ed3\u989d\u5916\u5173\u6ce8&#xff1a;\u626b\u63cf\u5b57\u8282\u6570\u3001\u5206\u533a\u88c1\u526a\u662f\u5426\u751f\u6548\u3001\u805a\u7c7b\u952e\u662f\u5426\u5408\u7406&#xff0c;\u8fd9\u4e9b\u76f4\u63a5\u7b49\u4e8e\u8ba1\u7b97\u6210\u672c\u3002<\/span><\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">8.4 OLTP \u5efa\u6a21\u539f\u5219<\/span><\/h3>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u9075\u5faa\u4e09\u8303\u5f0f&#xff0c;\u51cf\u5c11\u5197\u4f59&#xff0c;\u907f\u514d\u66f4\u65b0\u5f02\u5e38<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u660e\u786e\u4e3b\u952e\u3001\u5916\u952e\u4e0e\u7ea6\u675f&#xff0c;\u4fdd\u8bc1\u6570\u636e\u4e00\u81f4\u6027<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u56f4\u7ed5\u4e8b\u52a1\u4e0e\u70b9\u67e5\u8bbe\u8ba1&#xff0c;\u907f\u514d\u5927\u8868\u5bbd\u8868<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u9002\u5f53\u9884\u7559\u6269\u5c55\u5b57\u6bb5&#xff0c;\u5e94\u5bf9\u4e1a\u52a1\u8fed\u4ee3<\/span><\/li>\n<\/ul>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">8.5 OLAP \u6570\u4ed3\u5efa\u6a21<\/span><\/h3>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u661f\u578b\u6a21\u578b<\/span><\/h4>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4e8b\u5b9e\u8868&#xff1a;\u5ea6\u91cf\u4e1a\u52a1\u4e8b\u4ef6&#xff08;\u8ba2\u5355\u3001\u70b9\u51fb\u3001\u652f\u4ed8&#xff09;&#xff0c;\u5305\u542b\u5916\u952e\u4e0e\u6570\u503c\u5ea6\u91cf&#xff0c;\u5148\u5b9a\u7c92\u5ea6<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u7ef4\u5ea6\u8868&#xff1a;\u63cf\u8ff0\u5b9e\u4f53\u5c5e\u6027&#xff08;\u7528\u6237\u3001\u5546\u54c1\u3001\u65f6\u95f4\u3001\u6e20\u9053&#xff09;&#xff0c;\u4e3b\u952e\u5173\u8054\u4e8b\u5b9e\u8868<\/span><\/li>\n<\/ul>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u7f13\u6162\u53d8\u5316\u7ef4&#xff08;SCD&#xff09;<\/span><\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7ef4\u5ea6\u5c5e\u6027\u53d1\u751f\u53d8\u5316\u65f6\u7684\u5904\u7406\u65b9\u5f0f&#xff1a;<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">SCD Type 1&#xff1a;\u8986\u76d6\u66f4\u65b0&#xff0c;\u4e0d\u4fdd\u7559\u5386\u53f2<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">SCD Type 2&#xff1a;\u65b0\u589e\u884c&#xff0c;\u7528\u751f\u6548\u65f6\u95f4\/\u7248\u672c\u53f7\u533a\u5206\u5386\u53f2&#xff08;\u6700\u5e38\u7528&#xff09;<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">SCD Type 3&#xff1a;\u65b0\u589e\u5217\u4fdd\u5b58\u4e0a\u4e00\u4e2a\u503c<\/span><\/li>\n<\/ul>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u6570\u4ed3\u5206\u5c42\u601d\u60f3<\/span><\/h4>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:#f5f6f7;border-color:#dee0e3;width:414.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">ODS \u539f\u59cb\u5c42 \u2192 DWD \u660e\u7ec6\u5c42&#xff08;\u6e05\u6d17\u3001\u8131\u654f\u3001\u6807\u51c6\u5316&#xff09; \u2192 DWS \u6c47\u603b\u5c42&#xff08;\u8f7b\u5ea6\u805a\u5408&#xff09; \u2192 ADS \u5e94\u7528\u5c42&#xff08;\u62a5\u8868\/\u6307\u6807&#xff09;<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6bcf\u4e00\u5c42\u53ea\u505a\u4e00\u7c7b\u4e8b&#xff0c;SQL \u903b\u8f91\u6e05\u6670&#xff0c;\u8840\u7f18\u660e\u786e&#xff0c;\u4fbf\u4e8e\u7ef4\u62a4\u4e0e\u6392\u67e5\u95ee\u9898\u3002<\/span><\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">8.6 \u7c92\u5ea6&#xff08;Grain&#xff09;\u2014\u2014\u9ad8\u7ea7\u903b\u8f91\u6740\u624b<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u9519\u8bef\u793a\u4f8b&#xff1a;\u8ba2\u5355\u4e8b\u5b9e\u8868\u7c92\u5ea6\u662f\u300c\u4e00\u7b14\u8ba2\u5355\u4e00\u884c\u300d&#xff0c;JOIN \u300c\u8ba2\u5355\u4f18\u60e0\u660e\u7ec6\u8868\u300d&#xff08;\u4e00\u7b14\u8ba2\u5355\u591a\u4e2a\u4f18\u60e0&#xff09;\u540e&#xff0c;\u76f4\u63a5 SUM(order_amount)&#xff0c;\u8ba2\u5355\u91d1\u989d\u88ab\u653e\u5927\u4e86\u4f18\u60e0\u6761\u76ee\u6570\u500d\u3002<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6b63\u786e\u5bf9\u9f50\u6b65\u9aa4&#xff1a;<\/span><\/p>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5199\u660e\u6bcf\u4e2a\u8868\u7684\u7c92\u5ea6<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5173\u8054\u524d\u5148\u628a\u4e24\u4e2a\u8868\u805a\u5408\u5230\u76f8\u540c\u7c92\u5ea6<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u518d\u8fdb\u884c JOIN \u64cd\u4f5c<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u9a8c\u8bc1\u884c\u6570&#xff1a;JOIN \u524d\u540e\u884c\u6570\u662f\u5426\u7b26\u5408\u9884\u671f<\/span><\/li>\n<h2 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#7030a0\">\u7b2c 09 \u7ae0 \u00b7 \u73b0\u4ee3\u7279\u6027\u4e0e\u65b9\u8a00\u7248\u56fe&#xff08;\u9ad8\u7ea7&#xff09;<\/span><\/h2>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">9.1 \u9ad8\u7ea7 SQL \u8bed\u8a00\u7279\u6027<\/span><\/h3>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u591a\u7ef4\u6c47\u603b GROUPING SETS<\/span><\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4e00\u6b21\u67e5\u8be2\u751f\u6210\u591a\u4e2a\u7ef4\u5ea6\u7684\u805a\u5408\u7ed3\u679c&#xff0c;\u66ff\u4ee3\u591a\u6b21 UNION ALL&#xff1a;<\/span><\/p>\n<p>SELECT region, category, SUM(amount) AS total<br \/>\nFROM sales<br \/>\nGROUP BY GROUPING SETS (<br \/>\n\u00a0 (region, category),\u00a0 &#8212; \u533a\u57df&#043;\u7c7b\u76ee<br \/>\n\u00a0 (region),\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8212; \u533a\u57df\u6c47\u603b<br \/>\n\u00a0 ()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8212; \u5168\u5c40\u603b\u8ba1<br \/>\n); <\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u8fd8\u6709 <span style=\"background-color:#eff0f1\">ROLLUP<\/span>&#xff08;\u5c42\u7ea7\u6c47\u603b&#xff09;\u3001<span style=\"background-color:#eff0f1\">CUBE<\/span>&#xff08;\u5168\u7ef4\u5ea6\u7ec4\u5408&#xff09;\u4e24\u79cd\u7b80\u5316\u5199\u6cd5\u3002<\/span><\/p>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u884c\u6a21\u5f0f\u5339\u914d MATCH_RECOGNIZE<\/span><\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">SQL:2016 \u5f15\u5165&#xff0c;\u5728\u6709\u5e8f\u6570\u636e\u4e0a\u8bc6\u522b\u884c\u4e3a\u6a21\u5f0f&#xff08;\u5982\u8fde\u7eed\u767b\u5f55\u3001\u4f1a\u8bdd\u5207\u5272\u3001\u7528\u6237\u8def\u5f84&#xff09;&#xff0c;\u90e8\u5206\u5f15\u64ce\u652f\u6301\u3002<\/span><\/p>\n<h4 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#00b0f0\">\u8fc7\u7a0b\u5316\u80fd\u529b<\/span><\/h4>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5b58\u50a8\u8fc7\u7a0b\u3001\u81ea\u5b9a\u4e49\u51fd\u6570&#xff08;UDF&#xff09;\u65b9\u8a00\u5dee\u5f02\u6781\u5927\u3002\u539f\u5219&#xff1a;\u80fd\u7528\u96c6\u5408\u5199\u6cd5\u89e3\u51b3&#xff0c;\u5c31\u4e0d\u8981\u5199\u9010\u884c\u5faa\u73af\u7684\u5b58\u50a8\u8fc7\u7a0b&#xff0c;\u6027\u80fd\u4e0e\u53ef\u7ef4\u62a4\u6027\u90fd\u5dee\u3002<\/span><\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">9.2 JSON \u4e0e\u534a\u7ed3\u6784\u5316\u6570\u636e<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">SQL:2016 \u5f15\u5165\u539f\u751f JSON \u652f\u6301&#xff0c;SQL:2023 \u8fdb\u4e00\u6b65\u5f3a\u5316\u3002\u73b0\u5b9e\u4e2d\u5927\u91cf\u4e8b\u4ef6\u65e5\u5fd7\u3001\u63a5\u53e3\u6570\u636e\u90fd\u662f JSON \u683c\u5f0f\u3002<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5e38\u89c1\u64cd\u4f5c<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5b58\u50a8&#xff1a;\u6587\u672c \/ \u539f\u751f JSON \/ \u4e8c\u8fdb\u5236 JSON&#xff08;PostgreSQL JSONB&#xff0c;\u63a8\u8350&#xff09;<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u63d0\u53d6&#xff1a;\u6309\u8def\u5f84\u53d6\u503c&#xff0c;<span style=\"background-color:#eff0f1\">jsonb_extract_path_text<\/span>\u3001<span style=\"background-color:#eff0f1\">-&gt;<\/span>\u3001<span style=\"background-color:#eff0f1\">-&gt;&gt;<\/span> \u64cd\u4f5c\u7b26<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5c55\u5f00&#xff1a;\u6570\u7ec4\u8f6c\u884c&#xff0c;<span style=\"background-color:#eff0f1\">jsonb_array_elements<\/span>\u3001<span style=\"background-color:#eff0f1\">JSON_TABLE<\/span><\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6784\u9020&#xff1a;\u4ece\u884c\u6570\u636e\u6784\u9020 JSON \u5bf9\u8c61<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u7d22\u5f15&#xff1a;GIN \u7d22\u5f15\u52a0\u901f JSON \u952e\u503c\u67e5\u8be2<\/span><\/li>\n<\/ul>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">9.3 \u590d\u6742\u7c7b\u578b&#xff1a;\u6570\u7ec4 \/ Map \/ Struct<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">BigQuery\u3001Spark SQL\u3001DuckDB \u7b49\u5206\u6790\u5f15\u64ce\u5e7f\u6cdb\u652f\u6301\u5d4c\u5957\u7c7b\u578b&#xff1a;<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">ARRAY \u6570\u7ec4&#xff1a;\u591a\u503c\u5c5e\u6027&#xff0c;\u5982\u7528\u6237\u6807\u7b7e\u5217\u8868<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">Map \u952e\u503c\u5bf9&#xff1a;\u52a8\u6001\u5c5e\u6027<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">Struct \u7ed3\u6784\u4f53&#xff1a;\u590d\u5408\u5c5e\u6027&#xff0c;\u5982\u7528\u6237\u5730\u5740\u5305\u542b\u7701\u3001\u5e02\u3001\u533a<\/span><\/li>\n<\/ul>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5206\u6790\u573a\u666f\u5e38\u9700\u8981\u300c\u7206\u70b8\u5c55\u5f00\u300d&#xff08;UNNEST&#xff09;\u540e\u518d\u5173\u8054\u805a\u5408\u3002<\/span><\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">9.4 \u5c5e\u6027\u56fe\u67e5\u8be2 SQL\/PGQ<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">SQL:2023 \u65b0\u589e Part 16&#xff0c;\u628a\u8868\u6570\u636e\u5f53\u4f5c\u5c5e\u6027\u56fe&#xff0c;\u7528 <span style=\"background-color:#eff0f1\">GRAPH_TABLE<\/span> &#043; <span style=\"background-color:#eff0f1\">MATCH<\/span> \u505a\u8def\u5f84\u6a21\u5f0f\u67e5\u8be2&#xff0c;\u51cf\u5c11\u8d85\u6df1 JOIN \u7684\u8868\u8fbe\u8d1f\u62c5\u3002 2026 \u5e74\u73b0\u72b6&#xff1a;\u6807\u51c6\u5df2\u5b9a&#xff0c;\u4e3b\u6d41\u5f15\u64ce\u843d\u5730\u8fdb\u5ea6\u4e0d\u4e00&#xff0c;\u5c5e\u4e8e\u524d\u6cbf\u4e86\u89e3\u9879&#xff0c;\u56e2\u961f\u672a\u91c7\u7528\u65f6\u4e0d\u5fc5\u6df1\u6316\u3002<\/span><\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">9.5 \u4e3b\u6d41\u5f15\u64ce\u65b9\u8a00\u7248\u56fe<\/span><\/h3>\n<table cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u573a\u666f<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4ee3\u8868\u5f15\u64ce<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u590d\u4e60\u91cd\u70b9<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#fff2cc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u901a\u7528 OLTP<\/span><\/p>\n<\/td>\n<td style=\"background-color:#fff2cc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">PostgreSQL<\/span><\/p>\n<\/td>\n<td style=\"background-color:#fff2cc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">JSONB\u3001\u7a97\u53e3\u51fd\u6570\u3001\u7d22\u5f15\u7c7b\u578b\u3001\u4e8b\u52a1<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">Web \u751f\u6001 OLTP<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">MySQL<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7d22\u5f15\u3001InnoDB \u7279\u6027\u3001\u4e8b\u52a1\u9694\u79bb<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#fff2cc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u672c\u5730\u5206\u6790<\/span><\/p>\n<\/td>\n<td style=\"background-color:#fff2cc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">DuckDB<\/span><\/p>\n<\/td>\n<td style=\"background-color:#fff2cc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u53cb\u597d\u8bed\u6cd5\u3001\u5217\u5f0f\u6267\u884c\u3001\u6587\u4ef6\u67e5\u8be2<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4e91\u6570\u4ed3<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">Snowflake \/ BigQuery<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5206\u533a\u3001\u805a\u7c7b\u3001\u626b\u63cf\u6210\u672c\u3001\u534a\u7ed3\u6784\u5316<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#fff2cc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5b9e\u65f6\u5206\u6790<\/span><\/p>\n<\/td>\n<td style=\"background-color:#fff2cc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">ClickHouse \/ StarRocks<\/span><\/p>\n<\/td>\n<td style=\"background-color:#fff2cc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5217\u5f0f\u5b58\u50a8\u3001\u7269\u5316\u89c6\u56fe\u3001\u805a\u5408\u4f18\u5316<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6e56\u4ed3\u4e00\u4f53<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">Spark SQL \/ Databricks<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u7c7b\u578b\u7cfb\u7edf\u3001ANSI \u6a21\u5f0f\u3001UDF<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#fff2cc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5206\u5e03\u5f0f HTAP<\/span><\/p>\n<\/td>\n<td style=\"background-color:#fff2cc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">TiDB \/ OceanBase<\/span><\/p>\n<\/td>\n<td style=\"background-color:#fff2cc;width:138.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u517c\u5bb9 MySQL\/Oracle\u3001\u5206\u5e03\u5f0f\u4e8b\u52a1<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">DuckDB \u53cb\u597d\u8bed\u6cd5\u793a\u4f8b&#xff08;\u4e86\u89e3&#xff09;<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">GROUP BY ALL<\/span> \/ <span style=\"background-color:#eff0f1\">ORDER BY ALL<\/span>&#xff1a;\u81ea\u52a8\u6309 SELECT \u4e2d\u975e\u805a\u5408\u5217\u5206\u7ec4\/\u6392\u5e8f<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">SELECT * EXCEPT (col1, col2)<\/span>&#xff1a;\u6392\u9664\u6307\u5b9a\u5217<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\"><span style=\"background-color:#eff0f1\">FROM-first<\/span> \u5199\u6cd5&#xff1a;\u5148\u5199 FROM \u518d\u5199 SELECT&#xff0c;\u7f16\u8f91\u5668\u8865\u5168\u66f4\u53cb\u597d<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u8de8\u5f15\u64ce\u8fc1\u79fb\u65f6\u6536\u655b\u5230\u6807\u51c6 SQL&#xff0c;\u907f\u514d\u65b9\u8a00\u4f9d\u8d56<\/span><\/li>\n<\/ul>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">9.6 \u8de8\u65b9\u8a00\u8fc1\u79fb\u68c0\u67e5\u8868<\/span><\/h3>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u65e5\u671f\u51fd\u6570\u4e0e\u65f6\u533a\u5904\u7406\u5dee\u5f02<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5b57\u7b26\u4e32\u62fc\u63a5\u3001\u6b63\u5219\u3001\u622a\u53d6\u51fd\u6570\u5dee\u5f02<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5206\u9875\u8bed\u6cd5&#xff1a;LIMIT vs TOP vs FETCH FIRST<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">UPSERT\/MERGE \u8bed\u6cd5\u5dee\u5f02<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u8fd1\u4f3c\u53bb\u91cd\u3001\u8fd1\u4f3c\u5206\u4f4d\u6570\u7b49\u9ad8\u7ea7\u51fd\u6570<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4fdd\u7559\u5b57\u4e0e\u6807\u8bc6\u7b26\u5f15\u7528&#xff1a;\u53cc\u5f15\u53f7 vs \u53cd\u5f15\u53f7<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u7a7a\u503c\u6392\u5e8f\u9ed8\u8ba4\u884c\u4e3a\u3001\u805a\u5408\u5bf9\u7a7a\u503c\u7684\u5904\u7406<\/span><\/li>\n<h2 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#7030a0\">\u7b2c 10 \u7ae0 \u00b7 \u5206\u6790\u5de5\u7a0b&#xff08;\u9ad8\u7ea7\u5ef6\u4f38&#xff09;<\/span><\/h2>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5206\u6790\u5de5\u7a0b\u628a\u300c\u5199 SQL\u300d\u5347\u7ea7\u4e3a\u300c\u5de5\u7a0b\u5316\u4ea4\u4ed8\u6570\u636e\u4ea7\u54c1\u300d&#xff0c;\u662f\u6570\u636e\u56e2\u961f\u89c4\u6a21\u5316\u7684\u5fc5\u7ecf\u4e4b\u8def\u3002<\/span><\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">10.1 SQL \u5728\u6570\u636e\u7ba1\u9053\u4e2d\u7684\u4f4d\u7f6e<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5178\u578b\u6570\u636e\u94fe\u8def&#xff1a;<\/span><\/p>\n<table border=\"1\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:#f5f6f7;border-color:#dee0e3;width:414.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4e1a\u52a1\u6e90\u7cfb\u7edf \u2192 \u6570\u636e\u540c\u6b65&#xff08;CDC\/ETL&#xff09; \u2192 \u6570\u4ed3 ODS \u2192 DWD\/DWS \u8f6c\u6362&#xff08;SQL\/dbt&#xff09; \u2192 ADS \u6307\u6807\u5c42 \u2192 \u62a5\u8868\/BI\/\u5e94\u7528<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4f60\u5199\u7684 CTE \u5206\u5c42\u903b\u8f91&#xff0c;\u843d\u5230\u5de5\u7a0b\u91cc\u5c31\u662f\u6a21\u578b\u5206\u5c42\u4e0e\u4f9d\u8d56\u56fe\u3002<\/span><\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">10.2 \u6570\u636e\u8d28\u91cf&#xff1a;\u7528 SQL \u505a\u65ad\u8a00<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u9ad8\u8d28\u91cf\u6570\u636e\u662f\u5206\u6790\u53ef\u4fe1\u7684\u57fa\u7840&#xff0c;\u81f3\u5c11\u8986\u76d6\u56db\u7c7b\u6d4b\u8bd5&#xff1a;<\/span><\/p>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u552f\u4e00\u6027&#xff1a;\u4e3b\u952e\u4e0d\u91cd\u590d <span style=\"background-color:#eff0f1\">COUNT(*) &#061; COUNT(DISTINCT pk)<\/span><\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u975e\u7a7a&#xff1a;\u5173\u952e\u5b57\u6bb5\u6ca1\u6709 NULL<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5f15\u7528\u5b8c\u6574\u6027&#xff1a;\u4e8b\u5b9e\u8868\u5916\u952e\u90fd\u80fd\u5728\u7ef4\u5ea6\u8868\u4e2d\u627e\u5230<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4e1a\u52a1\u89c4\u5219&#xff1a;\u91d1\u989d \u2265 0\u3001\u7ed3\u675f\u65f6\u95f4 \u2265 \u5f00\u59cb\u65f6\u95f4\u3001\u72b6\u6001\u503c\u5728\u679a\u4e3e\u5185<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6ce2\u52a8\u76d1\u63a7&#xff1a;\u884c\u6570\u3001\u6307\u6807\u503c\u76f8\u5bf9\u6628\u65e5\/\u4e0a\u5468\u5f02\u5e38\u6ce2\u52a8<\/span><\/li>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5728 dbt \u4e2d\u4f53\u73b0\u4e3a&#xff1a;unique\u3001not_null\u3001relationships\u3001\u81ea\u5b9a\u4e49 SQL \u6d4b\u8bd5\u3002<\/span><\/p>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">10.3 \u589e\u91cf\u3001\u5e42\u7b49\u4e0e\u8fdf\u5230\u6570\u636e<\/span><\/h3>\n<table cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background-color:white;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6982\u5ff5<\/span><\/p>\n<\/td>\n<td style=\"background-color:white;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u542b\u4e49<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#ededed;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u589e\u91cf<\/span><\/p>\n<\/td>\n<td style=\"background-color:#ededed;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u6bcf\u6b21\u53ea\u5904\u7406\u65b0\u589e\/\u53d8\u66f4\u6570\u636e&#xff0c;\u800c\u975e\u5168\u91cf\u91cd\u7b97&#xff0c;\u8282\u7701\u8d44\u6e90<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"vertical-align:top;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5e42\u7b49<\/span><\/p>\n<\/td>\n<td style=\"vertical-align:top;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u540c\u4e00\u6279\u6570\u636e\u8dd1\u591a\u6b21&#xff0c;\u7ed3\u679c\u5b8c\u5168\u4e00\u81f4&#xff0c;\u53ef\u91cd\u590d\u6267\u884c<\/span><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"background-color:#ededed;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u8fdf\u5230\u6570\u636e<\/span><\/p>\n<\/td>\n<td style=\"background-color:#ededed;width:207.0pt\">\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u4e8b\u4ef6\u53d1\u751f\u65f6\u95f4\u665a\u4e8e\u6570\u636e\u5230\u8fbe\u65f6\u95f4&#xff0c;\u9700\u8981\u56de\u8865\u5386\u53f2\u7a97\u53e3<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">\u5e38\u89c1\u5b9e\u73b0\u7b56\u7565&#xff1a;<\/span><\/p>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6309\u65e5\u671f\u5206\u533a\u8986\u76d6&#xff1a;\u6bcf\u6b21\u91cd\u8dd1\u5f53\u5929\/\u8fd1 N \u5929\u5206\u533a<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">Merge \u6309\u4e1a\u52a1\u952e\u66f4\u65b0&#xff1a;\u4e3b\u952e\u5b58\u5728\u5219\u66f4\u65b0&#xff0c;\u4e0d\u5b58\u5728\u5219\u63d2\u5165<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6c34\u4f4d\u7ebf&#xff08;Watermark&#xff09;&#xff1a;\u5b9a\u4e49\u8fdf\u5230\u9608\u503c&#xff0c;\u8d85\u8fc7\u9608\u503c\u4e0d\u518d\u66f4\u65b0<\/span><\/li>\n<\/ul>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">10.4 dbt \u5728 2026 \u5e74\u7684\u53d1\u5c55<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">dbt \u662f\u5206\u6790\u5de5\u7a0b\u7684\u4e8b\u5b9e\u6807\u51c6\u5de5\u5177&#xff0c;\u6838\u5fc3\u662f\u300cSQL \u4e3a\u4e2d\u5fc3 &#043; \u7248\u672c\u63a7\u5236 &#043; \u6d4b\u8bd5 &#043; \u6587\u6863 &#043; \u8840\u7f18\u300d\u3002<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">2026 \u5e74\u6838\u5fc3\u6f14\u8fdb&#xff1a;<\/span><\/p>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">dbt Core v2&#xff1a;\u8fd0\u884c\u65f6\u91cd\u5199&#xff0c;\u89e3\u6790\u901f\u5ea6\u5927\u5e45\u63d0\u5347&#xff0c;\u652f\u6301\u66f4\u5927\u89c4\u6a21\u9879\u76ee<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">dbt lint&#xff1a;\u5185\u7f6e SQL \u9759\u6001\u68c0\u67e5&#xff0c;\u517c\u5bb9 SQLFluff \u89c4\u5219&#xff0c;\u63d0\u4ea4\u524d\u53d1\u73b0\u95ee\u9898<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u8bed\u4e49\u5c42&#xff08;Semantic Layer&#xff09;&#xff1a;\u6307\u6807\u5b9a\u4e49\u7edf\u4e00&#xff0c;BI \u5de5\u5177\u76f4\u63a5\u8c03\u7528&#xff0c;\u907f\u514d\u53e3\u5f84\u4e0d\u4e00\u81f4<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">AI \u5f00\u53d1\u4ee3\u7406&#xff1a;\u5185\u7f6e dbt Developer Agent&#xff0c;\u7406\u89e3\u9879\u76ee\u4e0a\u4e0b\u6587&#xff0c;\u8f85\u52a9\u5199\u6a21\u578b\u4e0e\u6d4b\u8bd5<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u72b6\u6001\u611f\u77e5\u8fd0\u884c&#xff1a;\u53ea\u8fd0\u884c\u53d8\u66f4\u7684\u6a21\u578b\u53ca\u5176\u4e0b\u6e38&#xff0c;\u63d0\u5347\u5f00\u53d1\u6548\u7387<\/span><\/li>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">10.5 \u53ef\u8bfb\u6027\u4e0e\u534f\u4f5c\u89c4\u8303<\/span><\/h3>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u547d\u540d\u5373\u6587\u6863&#xff1a;\u8868\u540d\u3001\u5b57\u6bb5\u540d\u53cd\u6620\u4e1a\u52a1\u542b\u4e49\u4e0e\u7c92\u5ea6&#xff0c;\u5982 <span style=\"background-color:#eff0f1\">dws_user_order_di<\/span>&#xff08;\u7528\u6237\u8ba2\u5355\u65e5\u6c47\u603b&#xff09;<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5206\u5c42\u6e05\u6670&#xff1a;\u590d\u6742\u903b\u8f91\u7528 CTE \u5206\u6bb5&#xff0c;\u6bcf\u6bb5\u53ea\u505a\u4e00\u4ef6\u4e8b<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u786c\u7f16\u7801\u6ce8\u91ca&#xff1a;\u9b54\u6cd5\u6570\u5b57\u3001\u7279\u6b8a\u4e1a\u52a1\u89c4\u5219\u5fc5\u987b\u52a0\u6ce8\u91ca\u8bf4\u660e\u539f\u56e0<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u53e3\u5f84\u6c89\u6dc0&#xff1a;\u8f6c\u5316\u7387\u3001\u6d3b\u8dc3\u7528\u6237\u7b49\u6838\u5fc3\u6307\u6807&#xff0c;\u53e3\u5f84\u5199\u5728\u6587\u6863\/\u6ce8\u91ca\u91cc<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">Code Review \u6807\u51c6&#xff1a;\u5148\u770b\u903b\u8f91\u6b63\u786e\u6027&#xff0c;\u518d\u770b\u98ce\u683c\u4e0e\u6027\u80fd<\/span><\/li>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">10.6 AI \u65f6\u4ee3\u7684 SQL \u80fd\u529b<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:left\"><span style=\"color:#8eaadb\">AI \u53ef\u4ee5\u5feb\u901f\u751f\u6210\u521d\u7a3f&#xff0c;\u4f46\u5ba1\u8ba1 SQL\u3001\u9a8c\u8bc1\u7ed3\u679c\u3001\u628a\u63a7\u53e3\u5f84\u624d\u662f\u4eba\u7684\u6838\u5fc3\u7ade\u4e89\u529b\u3002 AI \u751f\u6210 SQL \u5fc5\u67e5\u6e05\u5355&#xff1a;<\/span><\/p>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u7ed3\u679c\u7c92\u5ea6\u662f\u5426\u6b63\u786e&#xff0c;\u884c\u6570\u662f\u5426\u7b26\u5408\u9884\u671f<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">JOIN \u662f\u5426\u5bfc\u81f4\u884c\u6570\u81a8\u80c0&#xff0c;\u805a\u5408\u662f\u5426\u88ab\u653e\u5927<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">NULL \u503c\u5904\u7406\u662f\u5426\u7b26\u5408\u4e1a\u52a1\u5b9a\u4e49<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u65e5\u671f\u8fb9\u754c\u662f\u5426\u6b63\u786e&#xff08;\u5de6\u95ed\u53f3\u5f00\u3001\u65f6\u533a&#xff09;<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u91cd\u590d\u4e1a\u52a1\u952e\u662f\u5426\u53bb\u91cd<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u5206\u533a\u88c1\u526a\u662f\u5426\u751f\u6548&#xff0c;\u4f1a\u4e0d\u4f1a\u626b\u5168\u8868<\/span><\/li>\n<h3 style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#1f4e79\">10.7 \u5b89\u5168\u4e0e\u6210\u672c\u610f\u8bc6<\/span><\/h3>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6700\u5c0f\u6743\u9650\u539f\u5219&#xff1a;\u8d26\u53f7\u53ea\u7ed9\u5fc5\u8981\u7684\u67e5\u8be2\u6743\u9650&#xff0c;\u7981\u6b62\u751f\u4ea7\u5e93\u9ad8\u6743\u9650<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u9632 SQL \u6ce8\u5165&#xff1a;\u4e1a\u52a1\u4ee3\u7801\u4e2d\u7981\u6b62\u5b57\u7b26\u4e32\u62fc\u63a5 SQL&#xff0c;\u4f7f\u7528\u53c2\u6570\u5316\u67e5\u8be2<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6570\u636e\u8131\u654f&#xff1a;\u654f\u611f\u5b57\u6bb5&#xff08;\u624b\u673a\u53f7\u3001\u8eab\u4efd\u8bc1\u3001\u91d1\u989d&#xff09;\u5206\u7ea7\u8131\u654f<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u884c\u7ea7\u5b89\u5168&#xff08;RLS&#xff09;&#xff1a;\u4e0d\u540c\u7528\u6237\u53ea\u80fd\u770b\u5230\u81ea\u5df1\u6743\u9650\u8303\u56f4\u5185\u7684\u6570\u636e<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6210\u672c\u6cbb\u7406&#xff1a;\u4e91\u4e0a\u6570\u4ed3\u6309\u626b\u63cf\u91cf\u8ba1\u8d39&#xff0c;\u907f\u514d\u65e0\u610f\u4e49\u7684\u5168\u8868\u626b\u63cf&#xff0c;\u5408\u7406\u8bbe\u7f6e\u5206\u533a\u4e0e\u805a\u7c7b<\/span><\/li>\n<\/ul>\n<h2 style=\"background-color:transparent;margin-left:0px;margin-right:0px;text-align:justify\"><span style=\"color:#7030a0\">\u9644\u5f55 A&#xff1a;SQL \u907f\u5751\u901f\u67e5\u8868<\/span><\/h2>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6c38\u8fdc\u4e0d\u8981\u5199 <span style=\"background-color:#eff0f1\">&#061; NULL<\/span>&#xff0c;\u7528 <span style=\"background-color:#eff0f1\">IS NULL<\/span><\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">NOT IN \u5b50\u67e5\u8be2\u6ce8\u610f\u6392\u9664 NULL&#xff0c;\u4f18\u5148\u7528 NOT EXISTS<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">LEFT JOIN \u8fc7\u6ee4\u6761\u4ef6\u5199 ON \u548c WHERE \u7ed3\u679c\u4e0d\u4e00\u6837<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">COUNT(col) \u4e0d\u8ba1 NULL&#xff0c;COUNT(*) \u8ba1\u6240\u6709\u884c<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u7a97\u53e3\u51fd\u6570\u7684 ROWS \u548c RANGE \u5728\u6392\u5e8f\u952e\u91cd\u590d\u65f6\u7ed3\u679c\u4e0d\u540c<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u51fd\u6570\u5305\u88f9\u7d22\u5f15\u5217\u4f1a\u5bfc\u81f4\u7d22\u5f15\u5931\u6548<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u6df1\u5206\u9875 OFFSET \u6027\u80fd\u5dee&#xff0c;\u7528\u6e38\u6807\u5206\u9875\u66ff\u4ee3<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">UNION \u4f1a\u53bb\u91cd\u6392\u5e8f&#xff0c;\u4e0d\u9700\u8981\u53bb\u91cd\u4e00\u5b9a\u7528 UNION ALL<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u4e00\u5bf9\u591a JOIN \u540e\u805a\u5408\u8981\u8b66\u60d5\u91d1\u989d\u88ab\u653e\u5927<\/span><\/li>\n<li style=\"text-align:left\"><span style=\"color:#8eaadb\">\u65e5\u671f\u8fc7\u6ee4\u7528\u5de6\u95ed\u53f3\u5f00&#xff0c;\u907f\u514d DATE() \u51fd\u6570\u5305\u88f9\u5217<\/span><\/li>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\">\n","protected":false},"excerpt":{"rendered":"<p>\u5f80\u671f\u94fe\u63a5&#xff1a;<br \/>\nSQL\u5b66\u4e60\u6587\u6863-CSDN\u535a\u5ba2<br \/>\n\u5173\u7cfb\u6570\u636e\u5e93\u6807\u51c6\u8bed\u8a00&#xff08;SQL&#xff09;- \u8f6f\u8003\u5907\u6218&#xff08;\u4e09\u5341\u4e00&#xff09;-CSDN\u535a\u5ba2<br \/>\n\u6570\u636e\u5e93\u7cfb\u7edf &#8211; \u6c47\u603b\u7bc7-CSDN\u535a\u5ba2<br \/>\n\u6570\u636e\u5e93\u4e8b\u52a1\u4e0e\u5e76\u53d1\u63a7\u5236 &#8211; \u8f6f\u8003\u5907\u6218&#xff08;\u4e09\u5341\u4e8c&#xff09;-CSDN\u535a\u5ba2<br \/>\n\u5206\u5e03\u5f0f\u6570\u636e\u5e93 &#8211; \u8f6f\u8003\u5907\u6218&#xff08;\u4e09\u5341\u516d&#xff09;-CSDN\u535a\u5ba2<br \/>\n\u6570\u636e\u5e93\u57fa\u7840\u6982\u5ff5\u4e0e\u4f53\u7cfb\u7ed3\u6784 &#8211; \u8f6f\u8003\u5907\u6218&#xff08;\u4e8c\u5341\u4e5d&#xff09;-CSD<\/p>\n","protected":false},"author":2,"featured_media":88623,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[768,292,371,190,100],"topic":[],"class_list":["post-88624","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-sql","tag-292","tag-371","tag-190","tag-100"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>2026\u5e74\u7248-SQL\u5b66\u4e60\u6587\u6863 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/88624.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"2026\u5e74\u7248-SQL\u5b66\u4e60\u6587\u6863 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u5f80\u671f\u94fe\u63a5&#xff1a; SQL\u5b66\u4e60\u6587\u6863-CSDN\u535a\u5ba2 \u5173\u7cfb\u6570\u636e\u5e93\u6807\u51c6\u8bed\u8a00&#xff08;SQL&#xff09;- \u8f6f\u8003\u5907\u6218&#xff08;\u4e09\u5341\u4e00&#xff09;-CSDN\u535a\u5ba2 \u6570\u636e\u5e93\u7cfb\u7edf - \u6c47\u603b\u7bc7-CSDN\u535a\u5ba2 \u6570\u636e\u5e93\u4e8b\u52a1\u4e0e\u5e76\u53d1\u63a7\u5236 - \u8f6f\u8003\u5907\u6218&#xff08;\u4e09\u5341\u4e8c&#xff09;-CSDN\u535a\u5ba2 \u5206\u5e03\u5f0f\u6570\u636e\u5e93 - \u8f6f\u8003\u5907\u6218&#xff08;\u4e09\u5341\u516d&#xff09;-CSDN\u535a\u5ba2 \u6570\u636e\u5e93\u57fa\u7840\u6982\u5ff5\u4e0e\u4f53\u7cfb\u7ed3\u6784 - \u8f6f\u8003\u5907\u6218&#xff08;\u4e8c\u5341\u4e5d&#xff09;-CSD\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/88624.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-01T05:56:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801055640-6a6d8a9897ec8.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/88624.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/88624.html\",\"name\":\"2026\u5e74\u7248-SQL\u5b66\u4e60\u6587\u6863 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-01T05:56:44+00:00\",\"dateModified\":\"2026-08-01T05:56:44+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/88624.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/88624.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/88624.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"2026\u5e74\u7248-SQL\u5b66\u4e60\u6587\u6863\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"2026\u5e74\u7248-SQL\u5b66\u4e60\u6587\u6863 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/88624.html","og_locale":"zh_CN","og_type":"article","og_title":"2026\u5e74\u7248-SQL\u5b66\u4e60\u6587\u6863 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u5f80\u671f\u94fe\u63a5&#xff1a; SQL\u5b66\u4e60\u6587\u6863-CSDN\u535a\u5ba2 \u5173\u7cfb\u6570\u636e\u5e93\u6807\u51c6\u8bed\u8a00&#xff08;SQL&#xff09;- \u8f6f\u8003\u5907\u6218&#xff08;\u4e09\u5341\u4e00&#xff09;-CSDN\u535a\u5ba2 \u6570\u636e\u5e93\u7cfb\u7edf - \u6c47\u603b\u7bc7-CSDN\u535a\u5ba2 \u6570\u636e\u5e93\u4e8b\u52a1\u4e0e\u5e76\u53d1\u63a7\u5236 - \u8f6f\u8003\u5907\u6218&#xff08;\u4e09\u5341\u4e8c&#xff09;-CSDN\u535a\u5ba2 \u5206\u5e03\u5f0f\u6570\u636e\u5e93 - \u8f6f\u8003\u5907\u6218&#xff08;\u4e09\u5341\u516d&#xff09;-CSDN\u535a\u5ba2 \u6570\u636e\u5e93\u57fa\u7840\u6982\u5ff5\u4e0e\u4f53\u7cfb\u7ed3\u6784 - \u8f6f\u8003\u5907\u6218&#xff08;\u4e8c\u5341\u4e5d&#xff09;-CSD","og_url":"https:\/\/www.wsisp.com\/helps\/88624.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-01T05:56:44+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801055640-6a6d8a9897ec8.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"14 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/88624.html","url":"https:\/\/www.wsisp.com\/helps\/88624.html","name":"2026\u5e74\u7248-SQL\u5b66\u4e60\u6587\u6863 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-01T05:56:44+00:00","dateModified":"2026-08-01T05:56:44+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/88624.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/88624.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/88624.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"2026\u5e74\u7248-SQL\u5b66\u4e60\u6587\u6863"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/88624","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=88624"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/88624\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/88623"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=88624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=88624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=88624"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=88624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}